Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added bindings to tidyverse colnames - fix #69 #70

Merged
merged 1 commit into from
Jan 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions R/utils_Exposure.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ TreatmentExposure <- function(

# remove missing visits
dfEx <- dfEx %>%
filter( SUBJID != "" ) %>%
filter( INVID != "")
filter( .data$SUBJID != "" ) %>%
filter( .data$INVID != "")

# need to double check if any subjid has multiple INVIDs
if( anyDuplicated(dfEx %>% select(SUBJID,INVID) %>% distinct() ))
if( anyDuplicated(dfEx %>% select(.data$SUBJID,.data$INVID) %>% distinct() ))
stop( "SUBJID has multiple INVID assignments in visdt")

# Stop if snapshot date is not a date or NULL
Expand All @@ -55,27 +55,27 @@ TreatmentExposure <- function(
# Create a vector of IDs for those who are still on-going in study
if(!is.null(dfSdrg)){
completedIDs <- dfSdrg %>%
filter(SDRGYN_STD %in% c("Y","N") ) %>%
pull(SUBJID) %>%
filter(.data$SDRGYN_STD %in% c("Y","N") ) %>%
pull(.data$SUBJID) %>%
unique()
} else {
completedIDs<-c()
}

# calculate maximum treatment date
dfExRange <- dfEx %>%
select( SUBJID, INVID, EXSTDAT, EXENDAT ) %>%
group_by( SUBJID, INVID ) %>%
select( .data$SUBJID, .data$INVID, .data$EXSTDAT, .data$EXENDAT ) %>%
group_by( .data$SUBJID, .data$INVID ) %>%
summarise(
firstDoseDate = min( EXSTDAT, EXENDAT , na.rm=T),
firstDoseDate = min( .data$EXSTDAT, .data$EXENDAT , na.rm=T),
lastDoseDate = if_else(
first(SUBJID) %in% completedIDs,
as.Date(max( EXSTDAT, EXENDAT , na.rm=T)),
first(.data$SUBJID) %in% completedIDs,
as.Date(max( .data$EXSTDAT, .data$EXENDAT , na.rm=T)),
as.Date(dtSnapshot)
)
) %>%
mutate( Exposure = difftime(lastDoseDate, firstDoseDate, units="days" ) + 1) %>%
rename( SubjectID=SUBJID, SiteID=INVID)
mutate( Exposure = difftime(.data$lastDoseDate, .data$firstDoseDate, units="days" ) + 1) %>%
rename( SubjectID=.data$SUBJID, SiteID=.data$INVID)

return ( dfExRange )

Expand Down