| Title: | Create Tables, Listings and Figures using Functions Styled after SAS™ Macros |
|---|---|
| Description: | Mimic the style of traditional reporting macros for clinical trials. The purpose is to generate tables, listings and figures that support clinical research. This package is well suited for firms or individuals who wish to incorporate R without changing their ways of working as it follows a traditional clinical research workflow. Invoke functions (instead of macros) to summarize data and produce formatted reports. This package differs from others in that it includes tools (wrappers) for both analyzing and reporting data. |
| Authors: | Chris Rook [aut, cre], Yongwei Wang [aut], GlaxoSmithKline Research & Development Limited [cph, fnd] |
| Maintainer: | Chris Rook <[email protected]> |
| License: | Apache License (== 2.0) |
| Version: | 0.1.2 |
| Built: | 2026-05-12 08:46:52 UTC |
| Source: | https://github.com/gsk-biostatistics/repfun |
adae
adaeadae
A data frame with 105 columns:
Study Identifier
Domain Abbreviation
Unique Subject Identifier
Sequence Number
Sponsor-Defined Identifier
Reported Term for the Adverse Event
Lowest Level Term
Lowest Level Term Code
Dictionary-Derived Term
Preferred Term Code
High Level Term
High Level Term Code
High Level Group Term
High Level Group Term Code
Body System or Organ Class
Body System or Organ Class Code
Primary System Organ Class
Primary System Organ Class Code
Severity/Intensity
Serious Event
Action Taken with Study Treatment
Causality
Outcome of Adverse Event
Involves Cancer
Congenital Anomaly or Birth Defect
Persist or Signif Disability/Incapacity
Results in Death
Requires or Prolongs Hospitalization
Is Life Threatening
Occurred with Overdose
Date/Time of Collection
Start Date/Time of Adverse Event
End Date/Time of Adverse Event
Study Day of Start of Adverse Event
Study Day of End of Adverse Event
Date of First Exposure to Treatment
Date of Last Exposure to Treatment
Date of Death
End of Study Date
Analysis Start Date/Time
Analysis Start Date Imputation Flag
Analysis Start Time Imputation Flag
Analysis End Date/Time
Analysis End Date Imputation Flag
Analysis End Time Imputation Flag
Analysis Start Date
Analysis End Date
Analysis Start Relative Day
Analysis End Relative Day
Analysis Duration (N)
Analysis Duration Units
End Date/Time of Last Dose
Analysis Severity/Intensity
Analysis Causality
Treatment Emergent Analysis Flag
Analysis Severity/Intensity (N)
1st Max Sev./Int. Occurrence Flag
Subject Identifier for the Study
Subject Reference Start Date/Time
Subject Reference End Date/Time
Date/Time of First Study Treatment
Date/Time of Last Study Treatment
Date/Time of Informed Consent
Date/Time of End of Participation
Date/Time of Death
Subject Death Flag
Study Site Identifier
Age
Age Units
Sex
Race
Ethnicity
Planned Arm Code
Description of Planned Arm
Actual Arm Code
Description of Actual Arm
Country
Date/Time of Collection
Study Day of Collection
Planned Treatment for Period 01
Actual Treatment for Period 01
Datetime of First Exposure to Treatment
Time of First Exposure Imput. Flag
Datetime of Last Exposure to Treatment
Time of Last Exposure Imput. Flag
Total Treatment Duration (Days)
Screen Failure Date
End of Study Status
Final Retrievel Visit Date
Date of Randomization
undocumented field
Relative Day of Death
Elapsed Days from Last Dose to Death
undocumented field
undocumented field
undocumented field
Date Last Known Alive
Safety Population Flag
Pooled Race Group 1
Pooled Age Group 1
Geographic Region 1
Last Dose to Death - Days Elapsed Grp 1
Death Within 30 Days of Last Trt Flag
Death After 30 Days from Last Trt Flag
Death Within 30 Days of First Trt Flag
Adverse Events Analysis
Generated from admiral package (template ad_adae.R).
None
data("adae")data("adae")
adsl
adsladsl
A data frame with 54 columns:
Study Identifier
Unique Subject Identifier
Subject Identifier for the Study
Subject Reference Start Date/Time
Subject Reference End Date/Time
Date/Time of First Study Treatment
Date/Time of Last Study Treatment
Date/Time of Informed Consent
Date/Time of End of Participation
Date/Time of Death
Subject Death Flag
Study Site Identifier
Age
Age Units
Sex
Race
Ethnicity
Planned Arm Code
Description of Planned Arm
Actual Arm Code
Description of Actual Arm
Country
Date/Time of Collection
Study Day of Collection
Planned Treatment for Period 01
Actual Treatment for Period 01
Datetime of First Exposure to Treatment
Time of First Exposure Imput. Flag
Datetime of Last Exposure to Treatment
Time of Last Exposure Imput. Flag
Date of First Exposure to Treatment
Date of Last Exposure to Treatment
Total Treatment Duration (Days)
Screen Failure Date
End of Study Date
End of Study Status
Final Retrievel Visit Date
Date of Randomization
Date of Death
Date of Death Imputation Flag
Relative Day of Death
Elapsed Days from Last Dose to Death
undocumented field
undocumented field
undocumented field
Date Last Known Alive
Safety Population Flag
Pooled Race Group 1
Pooled Age Group 1
Geographic Region 1
Last Dose to Death - Days Elapsed Grp 1
Death Within 30 Days of Last Trt Flag
Death After 30 Days from Last Trt Flag
Death Within 30 Days of First Trt Flag
Subject Level Analysis
Generated from admiral package (template ad_adsl.R).
None
data("adsl")data("adsl")
advs
advsadvs
A data frame with 105 columns:
Study Identifier
Domain Abbreviation
Unique Subject Identifier
Sequence Number
Vital Signs Test Short Name
Vital Signs Test Name
Vital Signs Position of Subject
Result or Finding in Original Units
Original Units
Character Result/Finding in Std Format
Numeric Result/Finding in Standard Units
Standard Units
Completion Status
Location of Vital Signs Measurement
Baseline Flag
Visit Number
Visit Name
Planned Study Day of Visit
Date/Time of Measurements
Study Day of Vital Signs
Planned Time Point Name
Planned Time Point Number
Planned Elapsed Time from Time Point Ref
Time Point Reference
Date of First Exposure to Treatment
Date of Last Exposure to Treatment
Actual Treatment for Period 01
Planned Treatment for Period 01
Analysis Date
Analysis Relative Day
Parameter Code
Analysis Value
Analysis Timepoint (N)
Analysis Timepoint
Analysis Visit
Analysis Visit (N)
Derivation Type
On Treatment Record Flag
Analysis Normal Range Lower Limit
Analysis Normal Range Upper Limit
Analysis Range 1 Lower Limit
Analysis Range 1 Upper Limit
Analysis Reference Range Indicator
Baseline Type
Baseline Record Flag
Baseline Value
Baseline Reference Range Indicator
Change from Baseline
Percent Change from Baseline
Analysis Flag 01
Planned Treatment
Actual Treatment
Analysis Sequence Number
Analysis Value Category 1
Analysis Value Category 1 (N)
Parameter
Parameter (N)
Subject Identifier for the Study
Subject Reference Start Date/Time
Subject Reference End Date/Time
Date/Time of First Study Treatment
Date/Time of Last Study Treatment
Date/Time of Informed Consent
Date/Time of End of Participation
Date/Time of Death
Subject Death Flag
Study Site Identifier
Age
Age Units
Sex
Race
Ethnicity
Planned Arm Code
Description of Planned Arm
Actual Arm Code
Description of Actual Arm
Country
Date/Time of Collection
Study Day of Collection
Datetime of First Exposure to Treatment
Time of First Exposure Imput. Flag
Datetime of Last Exposure to Treatment
Time of Last Exposure Imput. Flag
Total Treatment Duration (Days)
Screen Failure Date
End of Study Date
End of Study Status
Final Retrievel Visit Date
Date of Randomization
Date of Death
undocumented field
Relative Day of Death
Elapsed Days from Last Dose to Death
undocumented field
undocumented field
undocumented field
Date Last Known Alive
Safety Population Flag
Pooled Race Group 1
Pooled Age Group 1
Geographic Region 1
Last Dose to Death - Days Elapsed Grp 1
Death Within 30 Days of Last Trt Flag
Death After 30 Days from Last Trt Flag
Death Within 30 Days of First Trt Flag
Vital Signs Analysis
Generated from admiral package (template ad_advs.R).
None
data("advs")data("advs")
An updated SDTM AE dataset that uses the CDISC pilot project
aeae
A data frame with 35 columns:
Study Identifier
Domain Abbreviation
Unique Subject Identifier
Sequence Number
Sponsor-Defined Identifier
Reported Term for the Adverse Event
Lowest Level Term
Lowest Level Term Code
Dictionary-Derived Term
Preferred Term Code
High Level Term
High Level Term Code
High Level Group Term
High Level Group Term Code
Body System or Organ Class
Body System or Organ Class Code
Primary System Organ Class
Primary System Organ Class Code
Severity/Intensity
Serious Event
Action Taken with Study Treatment
Causality
Outcome of Adverse Event
Involves Cancer
Congenital Anomaly or Birth Defect
Persist or Signif Disability/Incapacity
Results in Death
Requires or Prolongs Hospitalization
Is Life Threatening
Occurred with Overdose
Date/Time of Collection
Start Date/Time of Adverse Event
End Date/Time of Adverse Event
Study Day of Start of Adverse Event
Study Day of End of Adverse Event
Adverse Events
An updated SDTM AE dataset that uses the CDISC pilot project
Gopi Vegesna
Access the source of the Adverse Events dataset.
airquality_4test
airquality_4testairquality_4test
A data frame with 100 observations and 8 columns:
Ozone Score
Solar Score
Wind Score
Temperature
Month of Year
Day of Month
Dummy Character Variable 1
Dummy Character Variable 2
Updated version of the airquality data frame that includes filled NA values for testing.
Generated from repfun package.
None
data("airquality_4test")data("airquality_4test")
airquality_updated
airquality_updatedairquality_updated
A data frame with 100 observations and 8 columns:
Ozone Score
Solar Score
Wind Score
Temperature
Month of Year
Day of Month
Dummy Character Variable 1
Dummy Character Variable 2
Updated version of the airquality data frame that includes NA values.
Generated from repfun package.
None
data("airquality_updated")data("airquality_updated")
Copy all package data into a temporary directory that can be used when running examples.
copydata(p)copydata(p)
p |
A path as a string. |
'NULL' because package dataframes are copied to a folder.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) copydata(tempdir())library(repfun) copydata(tempdir())
A SDTM DM dataset from the CDISC pilot project
dmdm
A data frame with 25 columns:
Study Identifier
Domain Abbreviation
Unique Subject Identifier
Subject Identifier for the Study
Subject Reference Start Date/Time
Subject Reference End Date/Time
Date/Time of First Study Treatment
Date/Time of Last Study Treatment
Date/Time of Informed Consent
Date/Time of End of Participation
Date/Time of Death
Subject Death Flag
Study Site Identifier
Age
Age Units
Sex
Race
Ethnicity
Planned Arm Code
Description of Planned Arm
Actual Arm Code
Description of Actual Arm
Country
Date/Time of Collection
Study Day of Collection
Demography
A SDTM DM dataset from the CDISC pilot project
Access the source of the Demography dataset.
formats
formatsformats
A data frame with 5 columns and 8 observations:
Name of Format
Start Value of Format
End Value of Format
Label of Format
Type of Format
Formats Data Frame (SAS Style)
Generated for repfun package.
None
data("formats")data("formats")
mtcars_w2lbls
mtcars_w2lblsmtcars_w2lbls
A data frame with 32 observations and 11 columns:
Miles/(US) gallon
Number of cylinders
Displacement (cu.in.)
Gross horsepower
Rear axle ratio
Weight (1000 lbs)
1/4 mile time
Engine (0 = V-shaped, 1 = straight)
Transmission (0 = automatic, 1 = manual)
Number of forward gears
Number of carburetors
Updated version of the mtcars data frame that includes labels for 2 variables.
Generated from repfun package.
None
data("mtcars_w2lbls")data("mtcars_w2lbls")
Pass in an RTF file to have floating page numbers removed and result saved to the same file.
rem_pg_nums(infile)rem_pg_nums(infile)
infile |
A path to the RTF file as a string. |
'NULL' because floating page numbers are removed from rtf files.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
## Not run: library(repfun) repfun::rem_pg_nums('/path/to/an/rtf/file.rtf') ## End(Not run)## Not run: library(repfun) repfun::rem_pg_nums('/path/to/an/rtf/file.rtf') ## End(Not run)
Pass values to setup function and the global environment will be arranged for use reporting tools.
rs_setup( R_DICTION = "./inst/formats", R_MACDIRS = NULL, R_DDDATA = NULL, R_OTHERDATA = paste0("./data"), R_INPUTDATA = paste0("./data"), R_RAWDATA = paste0("./data"), R_SDTMDATA = paste0("./data"), R_ADAMDATA = paste0("./data"), R_RFMTDIR = paste0("./inst/formats"), D_CENTID = "SITEID", D_DATADATE = NULL, D_DSPLYNUM = 1, D_DSPLYTYP = "T", D_FONTSIZE = 10, D_KEEPPOPVARS = NULL, D_OUTFILE = "./inst/t_ru_list_1.rtf", D_PGMPTH = "./R/rs_setup.R", D_STUDYID = NULL, D_STUDY_DESC = NULL, D_POP = "ITTEFL", D_POPDATA = NULL, D_POPLBL = "Intent-to-Treat", D_SUBJID = "USUBJID", D_SUBPOP = NULL, D_SUBSET = NULL, D_TITLE1 = NULL, D_TITLE2 = NULL, D_TITLE3 = NULL, D_TITLE4 = NULL, D_TITLE5 = NULL, D_TITLE6 = NULL, D_TITLE7 = NULL, D_FOOT1 = NULL, D_FOOT2 = NULL, D_FOOT3 = NULL, D_FOOT4 = NULL, D_FOOT5 = NULL, D_FOOT6 = NULL, D_FOOT7 = NULL, D_FOOT8 = NULL, D_FOOT9 = NULL, D_USERID = Sys.getenv("USERNAME"), D_RTFYN = "N", D_DEBUG = 0, RetEnv = FALSE )rs_setup( R_DICTION = "./inst/formats", R_MACDIRS = NULL, R_DDDATA = NULL, R_OTHERDATA = paste0("./data"), R_INPUTDATA = paste0("./data"), R_RAWDATA = paste0("./data"), R_SDTMDATA = paste0("./data"), R_ADAMDATA = paste0("./data"), R_RFMTDIR = paste0("./inst/formats"), D_CENTID = "SITEID", D_DATADATE = NULL, D_DSPLYNUM = 1, D_DSPLYTYP = "T", D_FONTSIZE = 10, D_KEEPPOPVARS = NULL, D_OUTFILE = "./inst/t_ru_list_1.rtf", D_PGMPTH = "./R/rs_setup.R", D_STUDYID = NULL, D_STUDY_DESC = NULL, D_POP = "ITTEFL", D_POPDATA = NULL, D_POPLBL = "Intent-to-Treat", D_SUBJID = "USUBJID", D_SUBPOP = NULL, D_SUBSET = NULL, D_TITLE1 = NULL, D_TITLE2 = NULL, D_TITLE3 = NULL, D_TITLE4 = NULL, D_TITLE5 = NULL, D_TITLE6 = NULL, D_TITLE7 = NULL, D_FOOT1 = NULL, D_FOOT2 = NULL, D_FOOT3 = NULL, D_FOOT4 = NULL, D_FOOT5 = NULL, D_FOOT6 = NULL, D_FOOT7 = NULL, D_FOOT8 = NULL, D_FOOT9 = NULL, D_USERID = Sys.getenv("USERNAME"), D_RTFYN = "N", D_DEBUG = 0, RetEnv = FALSE )
R_DICTION |
Location of reporting dictionaries. |
R_MACDIRS |
List of folders to search for functions when they are invoked. |
R_DDDATA |
Location to write DDDATA reporting data sets. |
R_OTHERDATA |
Location of additional production data sets. |
R_INPUTDATA |
Location of permanent formats data sets and miscellaneous data sets. |
R_RAWDATA |
Location of raw data sets. |
R_SDTMDATA |
Location of SDTM data sets. |
R_ADAMDATA |
Location of ADAM data sets. |
R_RFMTDIR |
Location of format catalogs and corresponding lists. |
D_CENTID |
Variable name for investigational center. |
D_DATADATE |
Date of data sets for use in titles/footnotes. |
D_DSPLYNUM |
Display number for title. |
D_DSPLYTYP |
Type of Display ('T','L','F'). |
D_FONTSIZE |
Size of font on output file which is RTF by default (with automated PDF conversion via script). |
D_KEEPPOPVARS |
Variables to keep on the population data set when merging to apply populations and sub-populations. |
D_OUTFILE |
Production location for output TLFs. |
D_PGMPTH |
Path of the driver file that generates current outputs or data sets. |
D_STUDYID |
Protocol ID for the study. |
D_STUDY_DESC |
Description of Study. |
D_POP |
Population variable from ADSL that must equal Y for subjects to be included in the analysis. |
D_POPDATA |
Data set that contains the population to be analyzed. |
D_POPLBL |
Label for population being analyzed which can be used in the TLF header. |
D_SUBJID |
The variable used to uniquely identify a subject in this analysis. |
D_SUBPOP |
Condition to identify the sub-population when applied to ADSL. |
D_SUBSET |
Condition to filter data from incoming source data sets used for this TLF. |
D_TITLE1 |
First title text. |
D_TITLE2 |
Second title text. |
D_TITLE3 |
Third title text. |
D_TITLE4 |
Fourth title text. |
D_TITLE5 |
Fifth title text. |
D_TITLE6 |
Sixth title text. |
D_TITLE7 |
Seventh title text. |
D_FOOT1 |
First footnote text. |
D_FOOT2 |
Second footnote text. |
D_FOOT3 |
Third footnote text. |
D_FOOT4 |
Fourth footnote text. |
D_FOOT5 |
Fifth footnote text. |
D_FOOT6 |
Sixth footnote text. |
D_FOOT7 |
Seventh footnote text. |
D_FOOT8 |
Eighth footnote text. |
D_FOOT9 |
Ninth footnote text. |
D_USERID |
User name. |
D_RTFYN |
Y or N to generate RTf output. |
D_DEBUG |
Level of debugging to show in log files. |
RetEnv |
Return environment variable containing current settings. |
'NULL' because variables defined for use with the reporting tools.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) outdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"outdir") dir.create(outdir,showWarnings=FALSE) fmtdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"fmtdir") dir.create(fmtdir,showWarnings=FALSE) repfun::copydata(datdir) repfun::rs_setup( D_CENTID="SITEID", D_DATADATE=Sys.Date(), D_DSPLYNUM=1, D_DSPLYTYP='T', D_FONTSIZE=10, D_FOOT1='1.) Only treatment emergent events related to lipids are displayed.', D_FOOT2='2.) Subjects are counted once in each body system & preferred term.', D_KEEPPOPVARS=c('STUDYID','USUBJID','SAFFL'), D_USERID=Sys.getenv("USERNAME"), D_STUDYID='ABCXYZPDQ', D_POP="SAFFL", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL=='Y'), D_POPLBL="Safety", D_SUBJID=c("STUDYID","USUBJID"), D_TITLE1=paste0('Table 1: Summary of Treatment Emergent Adverse Events'), D_RTFYN="Y", D_DEBUG=0, R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, R_RFMTDIR=fmtdir, R_DDDATA=paste0(outdir,'/t_ru_list_1.rds'), D_OUTFILE=paste0(outdir,"/t_ru_list_1.rtf"), D_PGMPTH="/path/to/code/rs_setup.R")library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) outdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"outdir") dir.create(outdir,showWarnings=FALSE) fmtdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"fmtdir") dir.create(fmtdir,showWarnings=FALSE) repfun::copydata(datdir) repfun::rs_setup( D_CENTID="SITEID", D_DATADATE=Sys.Date(), D_DSPLYNUM=1, D_DSPLYTYP='T', D_FONTSIZE=10, D_FOOT1='1.) Only treatment emergent events related to lipids are displayed.', D_FOOT2='2.) Subjects are counted once in each body system & preferred term.', D_KEEPPOPVARS=c('STUDYID','USUBJID','SAFFL'), D_USERID=Sys.getenv("USERNAME"), D_STUDYID='ABCXYZPDQ', D_POP="SAFFL", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL=='Y'), D_POPLBL="Safety", D_SUBJID=c("STUDYID","USUBJID"), D_TITLE1=paste0('Table 1: Summary of Treatment Emergent Adverse Events'), D_RTFYN="Y", D_DEBUG=0, R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, R_RFMTDIR=fmtdir, R_DDDATA=paste0(outdir,'/t_ru_list_1.rds'), D_OUTFILE=paste0(outdir,"/t_ru_list_1.rtf"), D_PGMPTH="/path/to/code/rs_setup.R")
Pass in a data frame along with identification options and have Big N added to it.
ru_addbignvar( dsetintoaddbign, dsetintocount, countdistinctvars = c("STUDYID", "USUBJID"), groupbyvars = NULL, totalforvar = NULL, totalid = NULL, totaldecode = c("Total"), codedecodevarpairs = NULL, varcodelistpairs = NULL, codelistnames = list(), addbigntovarvalue = TRUE, splitchar = " " )ru_addbignvar( dsetintoaddbign, dsetintocount, countdistinctvars = c("STUDYID", "USUBJID"), groupbyvars = NULL, totalforvar = NULL, totalid = NULL, totaldecode = c("Total"), codedecodevarpairs = NULL, varcodelistpairs = NULL, codelistnames = list(), addbigntovarvalue = TRUE, splitchar = " " )
dsetintoaddbign |
The data set that will hold the derived big N value. |
dsetintocount |
The data set that will be counted to generate big N. |
countdistinctvars |
Variable(s) that contain values to be counted uniquely within any output grouping. |
groupbyvars |
Variables in DSETINTOCOUNT to group the data by when counting to deriving the big N. |
totalforvar |
Variable for which overall totals are required within all other grouped class variables. |
totalid |
Value(s) used to populate the variable(s) specified in totalforvar. |
totaldecode |
Value(s) used to populate the variable(s) of the decode variable(s) of the totalforvar. |
codedecodevarpairs |
Specifies code and decode variable pairs. Those variables should be in parameter GROUPBYVARSNUMER. One variable in the pair will contain the code, which is used in counting and ordering, and the other will contain decode, which is used for presentation. |
varcodelistpairs |
List of code/decode pairs of variables. |
codelistnames |
List of decodes for use with decoding code/decode pairs. |
addbigntovarvalue |
Place big N in a new variable or append to an existing variable (last groupbyvars value)? |
splitchar |
Text to insert between existing string and big N. |
A data frame based on the incoming data frame but collapsed by groups with descriptive statistics added.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) library(dplyr) library(tibble) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir"); dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN= ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) attr(G_POPDATA$TRT01AN,"label") <- 'Actual Treatment for Period 01 (n)' adae <- tibble::as_tibble(rfenv$adamdata$adae.rda()) %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) %>% dplyr::filter(TRTEMFL=='Y') addbign <- repfun::ru_addbignvar(adae, G_POPDATA, groupbyvars=c("TRT01AN", "TRT01A"), countdistinctvars=c("STUDYID", "USUBJID"), totalforvar=c("TRT01AN"), totalid = 99, totaldecode = 'Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), addbigntovarvalue=TRUE, splitchar="~") %>% dplyr::select(STUDYID, USUBJID, TRT01AN, TRT01A, AEBODSYS, AEDECOD)library(repfun) library(dplyr) library(tibble) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir"); dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN= ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) attr(G_POPDATA$TRT01AN,"label") <- 'Actual Treatment for Period 01 (n)' adae <- tibble::as_tibble(rfenv$adamdata$adae.rda()) %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) %>% dplyr::filter(TRTEMFL=='Y') addbign <- repfun::ru_addbignvar(adae, G_POPDATA, groupbyvars=c("TRT01AN", "TRT01A"), countdistinctvars=c("STUDYID", "USUBJID"), totalforvar=c("TRT01AN"), totalid = 99, totaldecode = 'Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), addbigntovarvalue=TRUE, splitchar="~") %>% dplyr::select(STUDYID, USUBJID, TRT01AN, TRT01A, AEBODSYS, AEDECOD)
Take incoming dataframe and add page number variable to it accounting for grouping variables, stacked variables, and no-split variables.
ru_addpage( dsetin, grpvars = NULL, stackvars = NULL, varlabls = NULL, rowsprbdy = NULL, startpaging = 0, lastbygrp = FALSE, fpage = "all", nftnotes = 0, nosplitvars = FALSE, npgvars = 0 )ru_addpage( dsetin, grpvars = NULL, stackvars = NULL, varlabls = NULL, rowsprbdy = NULL, startpaging = 0, lastbygrp = FALSE, fpage = "all", nftnotes = 0, nosplitvars = FALSE, npgvars = 0 )
dsetin |
The dataframe for which a paging variable will be added. |
grpvars |
Grouping variables used in the output (used for nosplitvars). |
stackvars |
Specify stacked grouping variables (reduces # of page lines available for data). |
varlabls |
Apply labels to outgoing dataframe. |
rowsprbdy |
Number of rows in the body of the report. |
startpaging |
Set to zero on first call, and > 0 on recalls to fix widows. |
lastbygrp |
Set to true if this page is processing the last value of the grouping variables (used when footnote is applied only to last page). |
fpage |
Setting to 'last' indicates that footnotes are only displayed on the last page. |
nftnotes |
Enter the number of footnotes (determines # of page lines available for data). |
nosplitvars |
Setting to true requires all values of the last grouping/stackvar must be on the same page (if possible). |
npgvars |
Number of page-by variables for this report (reduces # of page lines available for data). |
A dataframe based on the incoming dataframe but with a paging variable added.
Chris Rook, [email protected]
Yongwei Wang, [email protected]
library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir"); dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 001 (n)')) adae <- rfenv$adamdata$adae.rda() %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) aesum_t <- repfun::ru_freq( adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) %>% dplyr::mutate(ord1=ifelse(tt_summarylevel==0,0,1)) %>% dplyr::rename(ord2=tt_summarylevel) %>% dplyr::arrange(ord1,AEBODSYS,ord2,AEDECOD) %>% dplyr::select(-c(starts_with('tt_p'),starts_with('ord'))) aesum_p3 <- repfun::ru_addpage(aesum_t,grpvars=c('AEBODSYS'),rowsprbdy=35, nosplitvars=TRUE) print(head(aesum_p3,10))library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir"); dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 001 (n)')) adae <- rfenv$adamdata$adae.rda() %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) aesum_t <- repfun::ru_freq( adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) %>% dplyr::mutate(ord1=ifelse(tt_summarylevel==0,0,1)) %>% dplyr::rename(ord2=tt_summarylevel) %>% dplyr::arrange(ord1,AEBODSYS,ord2,AEDECOD) %>% dplyr::select(-c(starts_with('tt_p'),starts_with('ord'))) aesum_p3 <- repfun::ru_addpage(aesum_t,grpvars=c('AEBODSYS'),rowsprbdy=35, nosplitvars=TRUE) print(head(aesum_p3,10))
Pass in an SDTM data frame along with its Supplemental version and they will be combined.
ru_addsupp(dsetin, dsetinsupp)ru_addsupp(dsetin, dsetinsupp)
dsetin |
Incoming data frame to have supplemental data added. |
dsetinsupp |
The supplemental data set to add. |
The original SDTM data set with its supplemental data appended as new variables.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) library(knitr) ae <- repfun::ae suppae <- repfun::suppae aesupp <- repfun::ru_addsupp(dsetin=ae,dsetinsupp=suppae) knitr::kable(head(aesupp,5), caption = "SDTM.AE combined with SDTM.SUPPAE")library(repfun) library(knitr) ae <- repfun::ae suppae <- repfun::suppae aesupp <- repfun::ru_addsupp(dsetin=ae,dsetinsupp=suppae) knitr::kable(head(aesupp,5), caption = "SDTM.AE combined with SDTM.SUPPAE")
Pass in a data frame alignment criteria to have columns aligned for reporting.
ru_align( dsetin, varsin, byvars = NULL, alignment = "Right", compresschryn = "Y", ncspaces = 1 )ru_align( dsetin, varsin, byvars = NULL, alignment = "Right", compresschryn = "Y", ncspaces = 1 )
dsetin |
The data set holding the columns to align. |
varsin |
Columns to align. |
byvars |
Set of group-by variables. |
alignment |
Type of alignment. |
compresschryn |
Compress by removing leading and trailing spaces for the resulting aligned column? |
ncspaces |
Number of spaces between N and Percent. |
A data frame based having the requested columns aligned for reporting.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
#================= # Adverse Events #================= library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN= ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) attr(G_POPDATA$TRT01AN,"label") <- 'Actual Treatment for Period 01 (n)' adae <- rfenv$adamdata$adae.rda() %>% dplyr::select(-SAFFL) %>% repfun::ru_getdata(G_POPDATA, c("STUDYID", "USUBJID"), keeppopvars=c("TRT01AN", "TRT01A")) aesum_t <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) print('Before Aligning') print(head(aesum_t[,grep('(AEBODSYS|AEDECOD|tt_ac)',names(aesum_t))],20)) aesum_t_a <- repfun::ru_align(aesum_t, "tt_ac:") print('After Aligning') print(head(aesum_t_a[,grep('(AEBODSYS|AEDECOD|tt_ac)',names(aesum_t_a))],20)) #=========================== # Baseline Characteristics #=========================== rfenv <- repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) demstats_t <- repfun::ru_sumstats(G_POPDATA, analysisvars=c("AGE","TRTDURD"), groupbyvars=c("STUDYID","TRT01AN"), codedecodevarpairs=c("TRT01AN", "TRT01A"), totalforvar="TRT01AN", totalid=99, totaldecode="Total", statsinrowsyn = "Y", analysisvardps=list("AGE"=1,"TRTDURD"=2), statslist=c("n", "mean", "median", "sd", "min", "max")) %>% repfun::ru_denorm(varstodenorm=c("tt_result"), groupbyvars=c("tt_avid", "tt_avnm", "tt_svid", "tt_svnm"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac")) print('Before Aligning') print(head(demstats_t,10)) demstats_t_a <- repfun::ru_align(demstats_t, "tt_ac:", ncspaces=10) print('After Aligning') print(head(demstats_t_a,10))#================= # Adverse Events #================= library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN= ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) attr(G_POPDATA$TRT01AN,"label") <- 'Actual Treatment for Period 01 (n)' adae <- rfenv$adamdata$adae.rda() %>% dplyr::select(-SAFFL) %>% repfun::ru_getdata(G_POPDATA, c("STUDYID", "USUBJID"), keeppopvars=c("TRT01AN", "TRT01A")) aesum_t <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) print('Before Aligning') print(head(aesum_t[,grep('(AEBODSYS|AEDECOD|tt_ac)',names(aesum_t))],20)) aesum_t_a <- repfun::ru_align(aesum_t, "tt_ac:") print('After Aligning') print(head(aesum_t_a[,grep('(AEBODSYS|AEDECOD|tt_ac)',names(aesum_t_a))],20)) #=========================== # Baseline Characteristics #=========================== rfenv <- repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) demstats_t <- repfun::ru_sumstats(G_POPDATA, analysisvars=c("AGE","TRTDURD"), groupbyvars=c("STUDYID","TRT01AN"), codedecodevarpairs=c("TRT01AN", "TRT01A"), totalforvar="TRT01AN", totalid=99, totaldecode="Total", statsinrowsyn = "Y", analysisvardps=list("AGE"=1,"TRTDURD"=2), statslist=c("n", "mean", "median", "sd", "min", "max")) %>% repfun::ru_denorm(varstodenorm=c("tt_result"), groupbyvars=c("tt_avid", "tt_avnm", "tt_svid", "tt_svnm"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac")) print('Before Aligning') print(head(demstats_t,10)) demstats_t_a <- repfun::ru_align(demstats_t, "tt_ac:", ncspaces=10) print('After Aligning') print(head(demstats_t_a,10))
Pass in a data frame and the contents will be displayed.
ru_contents(dsetin)ru_contents(dsetin)
dsetin |
Incoming data frame to have proc contents generated. |
'NULL' because the proc contents output will be displayed.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) repfun::ru_contents(mtcars)library(repfun) repfun::ru_contents(mtcars)
Pass in a data set from a SAS format catalog (or similar) and have a list returned in the structure of a SAS format for decoding variables.
ru_data2codelist( dsetin, codelistvarname = "FMTNAME", codevarname = "START", decodevarname = "LABEL", typevarname = "TYPE" )ru_data2codelist( dsetin, codelistvarname = "FMTNAME", codevarname = "START", decodevarname = "LABEL", typevarname = "TYPE" )
dsetin |
Name of incoming data set structured as a SAS format catalog saved as a data set. |
codelistvarname |
Name of the variable containing the SAS format or similar. |
codevarname |
Name of the variable that holds the code value. |
decodevarname |
Name of the variable that holds the decode value. |
typevarname |
Type of format (character or numeric). |
A list based on the incoming data frame but with decode values added along with records when completetypes is true.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(R_RFMTDIR=datdir,RetEnv=TRUE) list <- repfun::ru_data2codelist(rfenv$rfmtdata$formats.rda()) list$SEXS$START[[1]] # Code value 1 list$SEXS$LABEL[[1]] # Decode value 1 list$SEXS$START[[2]] # Code value 2 list$SEXS$LABEL[[2]] # Decode value 2library(repfun) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(R_RFMTDIR=datdir,RetEnv=TRUE) list <- repfun::ru_data2codelist(rfenv$rfmtdata$formats.rda()) list$SEXS$START[[1]] # Code value 1 list$SEXS$LABEL[[1]] # Decode value 1 list$SEXS$START[[2]] # Code value 2 list$SEXS$LABEL[[2]] # Decode value 2
Pass in a base and compare data frame to find out if they are equal similar to proc compare in SAS.
ru_datacompare(dsetinbase, dsetincomp, idvars, maxprint = 50)ru_datacompare(dsetinbase, dsetincomp, idvars, maxprint = 50)
dsetinbase |
First data set. |
dsetincomp |
Second data set. |
idvars |
Match on these values prior to comparing records. |
maxprint |
Maximum number of differences per variable to display. |
An output similar to proc compare will be printed and returned as a list.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) repfun::ru_datacompare(iris,iris,idvars='Species')library(repfun) repfun::ru_datacompare(iris,iris,idvars='Species')
Pass in a data frame and variables ending in "DTC" will have corresponding numeric versions created and saved.
ru_datetime(dsetin, includevars = NULL)ru_datetime(dsetin, includevars = NULL)
dsetin |
Incoming data frame to have numeric datetimes added. |
includevars |
Specify which variables ending in DTC will be processed. |
The incoming data frame with numeric dates and times added will be returned.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) library(knitr) ae <- repfun::ru_datetime(repfun::ae) knitr::kable(head(ae[,grepl('(DT$|TM$|DTC$)',names(ae))],5), caption = "After Invoking ru_labels()")library(repfun) library(knitr) ae <- repfun::ru_datetime(repfun::ae) knitr::kable(head(ae[,grepl('(DT$|TM$|DTC$)',names(ae))],5), caption = "After Invoking ru_labels()")
Pass in a data frame along with identification options and have it transposed (denormalized, long to wide) to display treatment columns.
ru_denorm( dsetin, varstodenorm = NULL, groupbyvars = NULL, acrossvar = NULL, acrossvarlabel = NULL, acrossvarprefix = "tt_", acrossvarsuffix = NULL )ru_denorm( dsetin, varstodenorm = NULL, groupbyvars = NULL, acrossvar = NULL, acrossvarlabel = NULL, acrossvarprefix = "tt_", acrossvarsuffix = NULL )
dsetin |
The data set to transpose. |
varstodenorm |
The variables to transpose. |
groupbyvars |
Definition of one row in the output data frame. |
acrossvar |
Variable to define the columns in the transposed data frame. |
acrossvarlabel |
Variable to define the labels in the transposed data frame. |
acrossvarprefix |
Add to the beginning of each value in the across variable in the output data frame. |
acrossvarsuffix |
Add to the end of each value in the across variable in the output data frame. |
dsetin, varstodenorm=NULL, groupbyvars=NULL, acrossvar=NULL, acrossvarlabel=NULL, acrossvarprefix="tt_", acrossvarsuffix=NULL
A data frame based on the incoming data frame transposed from long to wide.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
#==================== # AEs: N and Percent #==================== library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) adae <- rfenv$adamdata$adae.rda() %>% select(-SAFFL) %>% repfun::ru_getdata(G_POPDATA, c("STUDYID", "USUBJID"), keeppopvars=c("TRT01AN", "TRT01A")) aesum_t <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) #====================================== # Demography Statistics: N and Percent #====================================== repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN= ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) demstats_t <- repfun::ru_sumstats(G_POPDATA, analysisvars=c("AGE","TRTDURD"), groupbyvars=c("STUDYID","TRT01AN"), codedecodevarpairs=c("TRT01AN", "TRT01A"), totalforvar="TRT01AN", totalid=99, totaldecode="Total", statsinrowsyn = "Y", analysisvardps=list("AGE"=1,"TRTDURD"=2), statslist=c("n", "mean", "median", "sd", "min", "max")) %>% repfun::ru_denorm(varstodenorm=c("tt_result"), groupbyvars=c("tt_avid", "tt_avnm", "tt_svid", "tt_svnm"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac"))#==================== # AEs: N and Percent #==================== library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) adae <- rfenv$adamdata$adae.rda() %>% select(-SAFFL) %>% repfun::ru_getdata(G_POPDATA, c("STUDYID", "USUBJID"), keeppopvars=c("TRT01AN", "TRT01A")) aesum_t <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) #====================================== # Demography Statistics: N and Percent #====================================== repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN= ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) demstats_t <- repfun::ru_sumstats(G_POPDATA, analysisvars=c("AGE","TRTDURD"), groupbyvars=c("STUDYID","TRT01AN"), codedecodevarpairs=c("TRT01AN", "TRT01A"), totalforvar="TRT01AN", totalid=99, totaldecode="Total", statsinrowsyn = "Y", analysisvardps=list("AGE"=1,"TRTDURD"=2), statslist=c("n", "mean", "median", "sd", "min", "max")) %>% repfun::ru_denorm(varstodenorm=c("tt_result"), groupbyvars=c("tt_avid", "tt_avnm", "tt_svid", "tt_svnm"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac"))
Pass in a data frame along with column/variable identifiers formatted with SAS Style (i.e., using colon) and it will be expanded to the actual variable list.
ru_expvarlist(dsetin, varsin = NULL, keepnotexist = FALSE)ru_expvarlist(dsetin, varsin = NULL, keepnotexist = FALSE)
dsetin |
A dataframe holding columns whose names will be expanded. |
varsin |
A SAS style list of variable names. |
keepnotexist |
If the variable does not exist on the dataframe it will be excluded from the list. |
A list of column/variable names.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) df <- data.frame(tt_ac01=c('1','2','3'), tt_ac02=c('a','b','b'), tt_ac03=c('10','11','12')) chk <- repfun::ru_expvarlist(df, varsin="tt_ac:") print(chk)library(repfun) df <- data.frame(tt_ac01=c('1','2','3'), tt_ac02=c('a','b','b'), tt_ac03=c('10','11','12')) chk <- repfun::ru_expvarlist(df, varsin="tt_ac:") print(chk)
Pass in a data frame with along code/decode variables and values to have missings populated.
ru_fillcodedcode( dsetin, codedecodevarpairs = NULL, varcodelistpairs = NULL, codelistnames = list(), groupbyvars = NULL, completetypes = TRUE )ru_fillcodedcode( dsetin, codedecodevarpairs = NULL, varcodelistpairs = NULL, codelistnames = list(), groupbyvars = NULL, completetypes = TRUE )
dsetin |
The data set that will be counted to generate numerators for counts and percents. |
codedecodevarpairs |
Specifies code and decode variable pairs. Those variables should be in parameter GROUPBYVARSNUMER. One variable in the pair will contain the code, which is used in counting and ordering, and the other will contain decode, which is used for presentation. |
varcodelistpairs |
List of code/decode pairs of variables. |
codelistnames |
List of decodes for use with decoding code/decode pairs. |
groupbyvars |
Set of by-variables used to merge the incoming data set with the decode data set. |
completetypes |
Keep all code/decode pairs even it not present on the incoming data set? |
A data frame based on the incoming data frame but with decode values added along with records when completetypes is true.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) fmtlist <- list('SEXS'=list('START'=list('M','F'), 'LABEL'=c('Male','Female'))) adsl <- repfun::adsl adsl2 <- repfun::ru_fillcodedcode(adsl, codedecodevarpairs=c("SEX", "SEXDCD"), varcodelistpairs=c("SEX", "SEXS"), codelistnames=fmtlist) unique(adsl2[c("SEX","SEXDCD")])library(repfun) fmtlist <- list('SEXS'=list('START'=list('M','F'), 'LABEL'=c('Male','Female'))) adsl <- repfun::adsl adsl2 <- repfun::ru_fillcodedcode(adsl, codedecodevarpairs=c("SEX", "SEXDCD"), varcodelistpairs=c("SEX", "SEXS"), codelistnames=fmtlist) unique(adsl2[c("SEX","SEXDCD")])
Pass in a data frame along with a vector of variables and a vector of fill values. (Default fill is 0 for numeric and blank " " for character.)
ru_fillna(dsetin, vars = NULL, fills = NULL)ru_fillna(dsetin, vars = NULL, fills = NULL)
dsetin |
Incoming data frame to have labels added to columns. |
vars |
Vector of variables to replace NA values. |
fills |
Vector of fill values. |
The incoming data frame with the requested NA values replaced.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) repfun::ru_fillna(airquality, vars=c('Ozone','Solar.R'), fills=c(1111,2222)) %>% head(10)library(repfun) repfun::ru_fillna(airquality, vars=c('Ozone','Solar.R'), fills=c(1111,2222)) %>% head(10)
Pass in a data frame along with identification options and have descriptive statistics derived.
ru_freq( dsetin, dsetindenom = NULL, countdistinctvars = NULL, groupbyvarsnumer = NULL, groupbyvarsdenom = NULL, resultstyle = "NUMERPCT", totalforvar = NULL, totalid = NULL, totaldecode = c("Total"), anyeventvars = NULL, anyeventvalues = NULL, codedecodevarpairs = NULL, varcodelistpairs = NULL, codelistnames = list(), groupminmaxvar = NULL, resultpctdps = 0 )ru_freq( dsetin, dsetindenom = NULL, countdistinctvars = NULL, groupbyvarsnumer = NULL, groupbyvarsdenom = NULL, resultstyle = "NUMERPCT", totalforvar = NULL, totalid = NULL, totaldecode = c("Total"), anyeventvars = NULL, anyeventvalues = NULL, codedecodevarpairs = NULL, varcodelistpairs = NULL, codelistnames = list(), groupminmaxvar = NULL, resultpctdps = 0 )
dsetin |
The data set that will be counted to generate descriptive statistics. |
dsetindenom |
Input dataset containing data to be counted to obtain the denominator. |
countdistinctvars |
Variable(s) that contain values to be counted uniquely within any output grouping. |
groupbyvarsnumer |
Variables in DSETINNUMER to group the data by when counting to obtain the numerator. |
groupbyvarsdenom |
Variables in DSETINDENOM to group the data by when counting to obtain the denominator. |
resultstyle |
The appearance style of the result columns that will be displayed in the report. |
totalforvar |
Variable for which overall totals are required within all other grouped class variables. |
totalid |
Value(s) used to populate the variable(s) specified in totalforvar. |
totaldecode |
Value(s) used to populate the variable(s) of the decode variable(s) of the totalforvar. |
anyeventvars |
Set of variables for which total rows will be added. |
anyeventvalues |
Set of text values for total rows generated above. |
codedecodevarpairs |
Specifies code and decode variable pairs. Those variables should be in parameter GROUPBYVARSNUMER. One variable in the pair will contain the code, which is used in counting and ordering, and the other will contain decode, which is used for presentation. |
varcodelistpairs |
List of code/decode pairs of variables. |
codelistnames |
List of decodes for use with decoding code/decode pairs. |
groupminmaxvar |
Specify if frequency of each group should be from first or last value of a variable in format MIN(variables). |
resultpctdps |
The reporting precision for percentages. |
A data frame based on the incoming data frame but collapsed by groups with descriptive statistics added.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) library(dplyr) library(tibble) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) outdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"outdir") dir.create(outdir,showWarnings=FALSE) fmtdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"fmtdir") dir.create(fmtdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) attr(G_POPDATA$TRT01AN,"label") <- 'Actual Treatment for Period 01 (n)' adae <- rfenv$adamdata$adae.rda() %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) aesum <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0)library(repfun) library(dplyr) library(tibble) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) outdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"outdir") dir.create(outdir,showWarnings=FALSE) fmtdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"fmtdir") dir.create(fmtdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) attr(G_POPDATA$TRT01AN,"label") <- 'Actual Treatment for Period 01 (n)' adae <- rfenv$adamdata$adae.rda() %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) aesum <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0)
Merge input data with population data to keep only subjects which are in population sub data,
ru_getdata( dsetin, dsetinpop = rfenv$G_POPDATA, subjidvars = c("STUDYID", "USUBJID"), subpop = rfenv$G_SUBPOP, pop = rfenv$G_POP, keeppopvars = rfenv$G_KEEPPOPVARS )ru_getdata( dsetin, dsetinpop = rfenv$G_POPDATA, subjidvars = c("STUDYID", "USUBJID"), subpop = rfenv$G_SUBPOP, pop = rfenv$G_POP, keeppopvars = rfenv$G_KEEPPOPVARS )
dsetin |
The data set that will be merged with the population data set. |
dsetinpop |
The population data set. |
subjidvars |
Variable(s) that define a unique subject. |
subpop |
A sub-population expression where variables are on DSETINPOP. |
pop |
The population expression (SAFFL=='Y'). |
keeppopvars |
Variables to keep on the population data set. |
A data frame based on the incoming data frame but restricted to the population of interest with relevant population variables added.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) outdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"outdir") dir.create(outdir,showWarnings=FALSE) fmtdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"fmtdir") dir.create(fmtdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl, D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3)), SAFFL=ifelse((row_number() %% 10) == 0,'N',SAFFL)) attr(G_POPDATA$TRT01AN,"label") <- 'Actual Treatment for Period 01 (n)' attr(G_POPDATA$SAFFL,"label") <- 'Safety Population Flag' adae <- rfenv$adamdata$adae.rda() %>% dplyr::select(-SAFFL) adae2 <- repfun::ru_getdata(adae, G_POPDATA, c("STUDYID", "USUBJID"), keeppopvars=c("TRT01AN", "TRT01A"))library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) outdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"outdir") dir.create(outdir,showWarnings=FALSE) fmtdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"fmtdir") dir.create(fmtdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POP="SAFFL", D_POPLBL="Safety", D_POPDATA=repfun::adsl, D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3)), SAFFL=ifelse((row_number() %% 10) == 0,'N',SAFFL)) attr(G_POPDATA$TRT01AN,"label") <- 'Actual Treatment for Period 01 (n)' attr(G_POPDATA$SAFFL,"label") <- 'Safety Population Flag' adae <- rfenv$adamdata$adae.rda() %>% dplyr::select(-SAFFL) adae2 <- repfun::ru_getdata(adae, G_POPDATA, c("STUDYID", "USUBJID"), keeppopvars=c("TRT01AN", "TRT01A"))
Pass in a vector of group-by variables along with a vector of code/decode pairs to have decode variables added or removed.
ru_groupbyvars(groupbyvars, codedecodevarpairs, adddecode = TRUE)ru_groupbyvars(groupbyvars, codedecodevarpairs, adddecode = TRUE)
groupbyvars |
Vector of group-by variables. |
codedecodevarpairs |
Specifies code and decode variable pairs. Those variables should be in parameter GROUPBYVARSNUMER. One variable in the pair will contain the code, which is used in counting and ordering, and the other will contain decode, which is used for presentation. |
adddecode |
Add decode variables (true) or remove (false). |
A data frame based on the incoming data frame but collapsed by groups with counts and percents added.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) add_decode <- repfun::ru_groupbyvars( c("TRTCD", "TRTGRP", "ATOXGRN", "AEDECOD", "AEBODSYS"), c("TRTCD", "TRTGRP", "ATOXGRN", "ATOXGR"), TRUE) rem_decode <- repfun::ru_groupbyvars( c("TRTCD", "TRTGRP", "ATOXGRN", "AEDECOD", "AEBODSYS"), c("TRTCD", "TRTGRP", "ATOXGRN", "ATOXGR"), FALSE)library(repfun) add_decode <- repfun::ru_groupbyvars( c("TRTCD", "TRTGRP", "ATOXGRN", "AEDECOD", "AEBODSYS"), c("TRTCD", "TRTGRP", "ATOXGRN", "ATOXGR"), TRUE) rem_decode <- repfun::ru_groupbyvars( c("TRTCD", "TRTGRP", "ATOXGRN", "AEDECOD", "AEBODSYS"), c("TRTCD", "TRTGRP", "ATOXGRN", "ATOXGR"), FALSE)
Pass in a data frame along with a named list of columns with their corresponding labels.
ru_labels(dsetin, varlabels = list(), style = c("base", "Hmisc"))ru_labels(dsetin, varlabels = list(), style = c("base", "Hmisc"))
dsetin |
Incoming data frame to have labels added to columns. |
varlabels |
List of variables and their labels. |
style |
Type of method used to add labels. |
The incoming data frame with labels added.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) df_with_labels <- ru_labels(mtcars,varlabels=list(mpg='Miles per gallon', cyl='Number of cylinders'))library(repfun) df_with_labels <- ru_labels(mtcars,varlabels=list(mpg='Miles per gallon', cyl='Number of cylinders'))
Provide a folder containing data sets/frames and have a list of function calls returned that can be used to quickly access individual data sets/frames.
ru_libname(datapath)ru_libname(datapath)
datapath |
Location of reporting data sets. |
List of function calls for use in quickly accessing individual data sets/frames.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) adamdata <- repfun::ru_libname(datdir) adamdata$adae.rda() %>% dplyr::filter(TRTEMFL=='Y') -> teae print(head(teae[,c(1:10)]),10)library(repfun) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) adamdata <- repfun::ru_libname(datdir) adamdata$adae.rda() %>% dplyr::filter(TRTEMFL=='Y') -> teae print(head(teae[,c(1:10)]),10)
Pass in a dataframe and reporting settings to have RTF output generated.
ru_list( dsetin, stackvar1 = NULL, stackvar2 = NULL, stackvar3 = NULL, stackvar4 = NULL, stackvar5 = NULL, stackvar6 = NULL, stackvar7 = NULL, stackvar8 = NULL, stackvar9 = NULL, stackvar10 = NULL, stackvar11 = NULL, stackvar12 = NULL, stackvar13 = NULL, stackvar14 = NULL, stackvar15 = NULL, display = "Y", varlabelstyle = "NOT IMPLEMENTED", dddatasetlabel = NULL, splitchar = "\n", getdatayn = "N", labelvarsyn = NULL, computebeforepagelines = NULL, computebeforepagevars = NULL, columns = NULL, ordervars = NULL, descending = NULL, orderformatted = "NOT IMPLEMENTED", orderfreq = "NOT IMPLEMENTED", orderdata = NULL, noprintvars = NULL, byvars = NULL, flowvars = "NOT IMPLEMENTED", widths = NULL, defaultwidths = "NOT IMPLEMENTED", skipvars = NULL, pagevars = NULL, idvars = NULL, linevars = NULL, centrevars = NULL, leftvars = NULL, rightvars = NULL, colspacing = 2, varspacing = "NOT IMPLEMENTED", formats = "NOT IMPLEMENTED", labels = NULL, break1 = "NOT IMPLEMENTED", break2 = "NOT IMPLEMENTED", break3 = "NOT IMPLEMENTED", break4 = "NOT IMPLEMENTED", break5 = "NOT IMPLEMENTED", nowidowvar = NULL, sharecolvars = NULL, sharecolvarsindent = 2, overallsummary = "n", proptions = "HEADLINE", denormyn = "N", varsToDenorm = NULL, groupByVars = NULL, acrossVar = NULL, acrossVarLabel = NULL, acrossColVarPrefix = NULL, acrossVarListName = NULL, lpp = 24, rpp = 50, toprow = "single", spanlbls = NULL, spanwidths = NULL, spanjust = NULL, spanbbord = NULL, spantbord = NULL, span2lbls = NULL, span2widths = NULL, span2just = NULL, span2bbord = NULL, xptyn = "N" )ru_list( dsetin, stackvar1 = NULL, stackvar2 = NULL, stackvar3 = NULL, stackvar4 = NULL, stackvar5 = NULL, stackvar6 = NULL, stackvar7 = NULL, stackvar8 = NULL, stackvar9 = NULL, stackvar10 = NULL, stackvar11 = NULL, stackvar12 = NULL, stackvar13 = NULL, stackvar14 = NULL, stackvar15 = NULL, display = "Y", varlabelstyle = "NOT IMPLEMENTED", dddatasetlabel = NULL, splitchar = "\n", getdatayn = "N", labelvarsyn = NULL, computebeforepagelines = NULL, computebeforepagevars = NULL, columns = NULL, ordervars = NULL, descending = NULL, orderformatted = "NOT IMPLEMENTED", orderfreq = "NOT IMPLEMENTED", orderdata = NULL, noprintvars = NULL, byvars = NULL, flowvars = "NOT IMPLEMENTED", widths = NULL, defaultwidths = "NOT IMPLEMENTED", skipvars = NULL, pagevars = NULL, idvars = NULL, linevars = NULL, centrevars = NULL, leftvars = NULL, rightvars = NULL, colspacing = 2, varspacing = "NOT IMPLEMENTED", formats = "NOT IMPLEMENTED", labels = NULL, break1 = "NOT IMPLEMENTED", break2 = "NOT IMPLEMENTED", break3 = "NOT IMPLEMENTED", break4 = "NOT IMPLEMENTED", break5 = "NOT IMPLEMENTED", nowidowvar = NULL, sharecolvars = NULL, sharecolvarsindent = 2, overallsummary = "n", proptions = "HEADLINE", denormyn = "N", varsToDenorm = NULL, groupByVars = NULL, acrossVar = NULL, acrossVarLabel = NULL, acrossColVarPrefix = NULL, acrossVarListName = NULL, lpp = 24, rpp = 50, toprow = "single", spanlbls = NULL, spanwidths = NULL, spanjust = NULL, spanbbord = NULL, spantbord = NULL, span2lbls = NULL, span2widths = NULL, span2just = NULL, span2bbord = NULL, xptyn = "N" )
dsetin |
Incoming data frame or list of data frames. |
stackvar1 |
Create Stacked variables (e.g. stackvar1=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar2 |
Create Stacked variables (e.g. stackvar2=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar3 |
Create Stacked variables (e.g. stackvar3=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar4 |
Create Stacked variables (e.g. stackvar4=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar5 |
Create Stacked variables (e.g. stackvar5=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar6 |
Create Stacked variables (e.g. stackvar6=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar7 |
Create Stacked variables (e.g. stackvar7=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar8 |
Create Stacked variables (e.g. stackvar8=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar9 |
Create Stacked variables (e.g. stackvar9=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar10 |
Create Stacked variables (e.g. stackvar10=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar11 |
Create Stacked variables (e.g. stackvar11=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar12 |
Create Stacked variables (e.g. stackvar12=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar13 |
Create Stacked variables (e.g. stackvar13=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar14 |
Create Stacked variables (e.g. stackvar14=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
stackvar15 |
Create Stacked variables (e.g. stackvar15=list(varsin=c('invid','subjid'), varout='st_inv_subj', sepc='/', splitc='\n')) |
display |
Specifies whether the report should be created |
varlabelstyle |
Specifies the label style for variables (SHORT or STD) |
dddatasetlabel |
Label to be applied to the DD dataset |
splitchar |
Split character |
getdatayn |
Control execution of tu_getdata |
labelvarsyn |
Control execution of tu_labelvars |
computebeforepagelines |
Specifies the text to be produced for the Compute Before Page lines (labelkey labelfmt colon labelvar) |
computebeforepagevars |
Names of variables that shall define the sort order for Compute Before Page lines |
columns |
Column parameter |
ordervars |
Order variables |
descending |
Descending ORDERVARS |
orderformatted |
ORDER=FORMATTED variables |
orderfreq |
ORDER=FREQ variables |
orderdata |
ORDER=DATA variables |
noprintvars |
No print vars (usually used to order the display) |
byvars |
By variables |
flowvars |
Variables with flow option |
widths |
Column widths |
defaultwidths |
List of default column widths |
skipvars |
similar to SAS statement skipvars Break after skip |
pagevars |
similar to SAS statement pagevars Break after page |
idvars |
ID variables |
linevars |
Order variable printed with line statements. |
centrevars |
Centre justify variables |
leftvars |
Left justify variables |
rightvars |
Right justify variables |
colspacing |
Overall spacing value. |
varspacing |
Spacing for individual variables. |
formats |
Format specification |
labels |
Label definitions. |
break1 |
Break statements. |
break2 |
Break statements. |
break3 |
Break statements. |
break4 |
Break statements. |
break5 |
Break statements. |
nowidowvar |
Not in version 1 |
sharecolvars |
Order variables that share print space. |
sharecolvarsindent |
Indentation factor |
overallsummary |
Overall summary line at top of tables |
proptions |
PROC REPORT statement options |
denormyn |
Controls whether denormalisation will occur |
varsToDenorm |
List of variables to be denormalised/transposed. Passed one at a time to the PROC TRANSPOSE VAR statement. |
groupByVars |
List of BY variables passed to PROC TRANSPOSE BY statement. |
acrossVar |
Variable used in the PROC TRANSPOSE ID statement. |
acrossVarLabel |
Variable used in the PROC TRANSPOSE IDLABEL statement. |
acrossColVarPrefix |
Text passed to the PROC TRANSPOSE PREFIX statement. |
acrossVarListName |
Macro variable name to contain the list of columns created by the transpose of the first variable in VARSTODENORM. |
lpp |
Lines within body of report (only used with manual paging). |
rpp |
Total lines per page, when there is no wrapping and excluding titles and footnotes - passed directly to r2rtf(). |
toprow |
Control lines above first column header. |
spanlbls |
List of level 1 column spanning header labels. |
spanwidths |
List of level 1 column spanning header widths. |
spanjust |
List of level 1 column spanning header justifications. |
spanbbord |
List of level 1 column spanning bottom border values. |
spantbord |
List of level 1 column spanning top border values. |
span2lbls |
List of level 2 column spanning header labels (above Level 1). |
span2widths |
List of level 2 column spanning header widths (above Level 1). |
span2just |
List of level 2 column spanning header justifications (above Level 1). |
span2bbord |
List of level 2 column spanning bottom border values (above Level 1). |
xptyn |
Write DDDATA data frame as XPT file in addition to RDS? |
'NULL' because a formatted RTF report is generated to the specified file.
Chris Rook, [email protected]
Yongwei Wang, [email protected]
library(repfun) library(dplyr) library(tibble) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) outdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"outdir") dir.create(outdir,showWarnings=FALSE) #=================================== # Set up the reporting environment. #=================================== setup <- function(tlfid){ myenv <- repfun::rs_setup( D_DATADATE=Sys.Date(), D_DSPLYNUM=tlfid, D_FOOT1='1.) Only treatment emergent events related to lipids are displayed.', D_FOOT2='2.) Subjects counted once in each body system & preferred term.', D_KEEPPOPVARS=c('STUDYID','USUBJID','SAFFL'), D_STUDYID='ABCXYZPDQ', D_POP="SAFFL", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y') %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels= list('TRT01AN'='Actual Treatment for Period 01 (n)')), D_POPLBL="Safety", D_SUBJID=c("STUDYID","USUBJID"), D_TITLE1=paste0('Table ',tlfid,': Summary of Treatment Emergent Adverse Events'), D_OUTFILE=paste0(outdir,"/t_ru_list_",tlfid,".rtf"), D_PGMPTH="/path/to/code/ru_list.R", R_DDDATA=paste0(outdir,'/t_ru_list_',tlfid,'.rds'), R_ADAMDATA=datdir, RetEnv=TRUE) return(myenv) } #============================================ # Process ADAE - derive counts and percents. #============================================ rfenv <- setup(1) aesum <- repfun::ru_freq(rfenv$adamdata$adae.rda() %>% dplyr::select(-SAFFL) %>% repfun::ru_getdata(rfenv$G_POPDATA, c("STUDYID", "USUBJID"), keeppopvars=c("TRT01AN", "TRT01A")), dsetindenom=rfenv$G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% dplyr::arrange(TRT01AN,TRT01A,AEBODSYS,tt_summarylevel,AEDECOD,NUMERCNT,DENOMCNT) %>% repfun::ru_align("tt_result") #========================================================================== # Table 2: Summary of Adverse Events using NOWIDOWVAR (remove SOCs that # will not fit on 1 page with 10pt font) #========================================================================== rfenv <- setup(2) SOCterms <- aesum %>% dplyr::distinct(AEBODSYS,AEDECOD) SOCcnts <- table(SOCterms$AEBODSYS) repfun::ru_list(aesum %>% dplyr::filter(!(AEBODSYS %in% names(SOCcnts[SOCcnts>=20]))), columns=c('AEBODSYS','AEDECOD','tt_01','tt_02','tt_03','tt_99'), nowidowvar='AEBODSYS', widths=c(5.5,4.5,1.75,1.9,1.9,1.75), skipvars=c('AEBODSYS'), centrevars=c('tt_01','tt_02','tt_03','tt_99'), ordervars=c('AEBODSYS','tt_summarylevel','AEDECOD'), noprintvars=c('tt_summarylevel'), denormyn='Y', varsToDenorm=c('tt_result'), groupByVars=c('AEBODSYS','tt_summarylevel','AEDECOD'), acrossVar="TRT01AN", acrossVarLabel="TRT01A", acrossColVarPrefix='tt_', dddatasetlabel=paste0('DD Dataframe for AE Table ',rfenv$G_DSPLYNUM), lpp=24)library(repfun) library(dplyr) library(tibble) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) outdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"outdir") dir.create(outdir,showWarnings=FALSE) #=================================== # Set up the reporting environment. #=================================== setup <- function(tlfid){ myenv <- repfun::rs_setup( D_DATADATE=Sys.Date(), D_DSPLYNUM=tlfid, D_FOOT1='1.) Only treatment emergent events related to lipids are displayed.', D_FOOT2='2.) Subjects counted once in each body system & preferred term.', D_KEEPPOPVARS=c('STUDYID','USUBJID','SAFFL'), D_STUDYID='ABCXYZPDQ', D_POP="SAFFL", D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y') %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels= list('TRT01AN'='Actual Treatment for Period 01 (n)')), D_POPLBL="Safety", D_SUBJID=c("STUDYID","USUBJID"), D_TITLE1=paste0('Table ',tlfid,': Summary of Treatment Emergent Adverse Events'), D_OUTFILE=paste0(outdir,"/t_ru_list_",tlfid,".rtf"), D_PGMPTH="/path/to/code/ru_list.R", R_DDDATA=paste0(outdir,'/t_ru_list_',tlfid,'.rds'), R_ADAMDATA=datdir, RetEnv=TRUE) return(myenv) } #============================================ # Process ADAE - derive counts and percents. #============================================ rfenv <- setup(1) aesum <- repfun::ru_freq(rfenv$adamdata$adae.rda() %>% dplyr::select(-SAFFL) %>% repfun::ru_getdata(rfenv$G_POPDATA, c("STUDYID", "USUBJID"), keeppopvars=c("TRT01AN", "TRT01A")), dsetindenom=rfenv$G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% dplyr::arrange(TRT01AN,TRT01A,AEBODSYS,tt_summarylevel,AEDECOD,NUMERCNT,DENOMCNT) %>% repfun::ru_align("tt_result") #========================================================================== # Table 2: Summary of Adverse Events using NOWIDOWVAR (remove SOCs that # will not fit on 1 page with 10pt font) #========================================================================== rfenv <- setup(2) SOCterms <- aesum %>% dplyr::distinct(AEBODSYS,AEDECOD) SOCcnts <- table(SOCterms$AEBODSYS) repfun::ru_list(aesum %>% dplyr::filter(!(AEBODSYS %in% names(SOCcnts[SOCcnts>=20]))), columns=c('AEBODSYS','AEDECOD','tt_01','tt_02','tt_03','tt_99'), nowidowvar='AEBODSYS', widths=c(5.5,4.5,1.75,1.9,1.9,1.75), skipvars=c('AEBODSYS'), centrevars=c('tt_01','tt_02','tt_03','tt_99'), ordervars=c('AEBODSYS','tt_summarylevel','AEDECOD'), noprintvars=c('tt_summarylevel'), denormyn='Y', varsToDenorm=c('tt_result'), groupByVars=c('AEBODSYS','tt_summarylevel','AEDECOD'), acrossVar="TRT01AN", acrossVarLabel="TRT01A", acrossColVarPrefix='tt_', dddatasetlabel=paste0('DD Dataframe for AE Table ',rfenv$G_DSPLYNUM), lpp=24)
Given a list of packages, check if installed and generate message, otherwise load package.
ru_load_library(pkgs)ru_load_library(pkgs)
pkgs |
A list of packages to check if installed and then load. |
'NULL' because packages are loaded.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) repfun::ru_load_library(c("dplyr", "haven", "magrittr", "r2rtf"))library(repfun) repfun::ru_load_library(c("dplyr", "haven", "magrittr", "r2rtf"))
Pass in a collection of data frames separated by commas and they will be appended.
ru_setdata(..., keeprownames = TRUE)ru_setdata(..., keeprownames = TRUE)
... |
A collection of data frames. |
keeprownames |
Convert row names on data frame to columns and keep the column. |
The incoming data frames combined (stacked).
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) repfun::ru_setdata(head(mtcars,5),head(airquality,5))library(repfun) repfun::ru_setdata(head(mtcars,5),head(airquality,5))
Pass in a dataframe and columns to stack and have new dataframe returned that contains the stacked columns.
ru_stackvar( dsetin, sepc = "/", splitc = "\\line", varsin = NULL, varout = NULL, varlabel = NULL )ru_stackvar( dsetin, sepc = "/", splitc = "\\line", varsin = NULL, varout = NULL, varlabel = NULL )
dsetin |
Name of incoming dataframe with columns to have stacked. |
sepc |
Separator character between the stacked columns. |
splitc |
Split character between stacked columns. |
varsin |
List of variables to be stacked. |
varout |
Name of stacked column in dataframe. |
varlabel |
Label for new stacked column. |
The incoming dataframe with columns stacked as requested.
Chris Rook, [email protected]
Yongwei Wang, [email protected]
library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) adae <- rfenv$adamdata$adae.rda() %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) aesum_p <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) %>% dplyr::mutate(ord1=ifelse(tt_summarylevel==0,0,1)) %>% dplyr::rename(ord2=tt_summarylevel) %>% dplyr::arrange(ord1,AEBODSYS,ord2,AEDECOD) %>% dplyr::select(-c(starts_with('tt_p'),starts_with('ord'))) %>% repfun::ru_stackvar(varsin=c('AEBODSYS','AEDECOD'),varout='SYSPREF', varlabel='Body System/Preferred Term')library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir") dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) adae <- rfenv$adamdata$adae.rda() %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) aesum_p <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) %>% dplyr::mutate(ord1=ifelse(tt_summarylevel==0,0,1)) %>% dplyr::rename(ord2=tt_summarylevel) %>% dplyr::arrange(ord1,AEBODSYS,ord2,AEDECOD) %>% dplyr::select(-c(starts_with('tt_p'),starts_with('ord'))) %>% repfun::ru_stackvar(varsin=c('AEBODSYS','AEDECOD'),varout='SYSPREF', varlabel='Body System/Preferred Term')
Pass in a data frame along with identification options and have descriptive statistics derived.
ru_sumstats( dsetin, analysisvars = NULL, analysisvarlabels = "", groupbyvars = NULL, statslist = c("n", "mean", "median", "min", "max", "sd", "q1", "q3"), statsinrowsyn = "N", analysisvardps = 0, statsdps = list(mean = 1, median = 1, sd = 2, se = 2), codedecodevarpairs = c(""), varcodelistpairs = c(""), codelistnames = list(), totalforvar = NULL, totalid = NULL, totaldecode = c("Total") )ru_sumstats( dsetin, analysisvars = NULL, analysisvarlabels = "", groupbyvars = NULL, statslist = c("n", "mean", "median", "min", "max", "sd", "q1", "q3"), statsinrowsyn = "N", analysisvardps = 0, statsdps = list(mean = 1, median = 1, sd = 2, se = 2), codedecodevarpairs = c(""), varcodelistpairs = c(""), codelistnames = list(), totalforvar = NULL, totalid = NULL, totaldecode = c("Total") )
dsetin |
The data set that will be ounted to generate descriptive statistics. |
analysisvars |
The variables to be analysed. |
analysisvarlabels |
Specify a label statement which will be used to defined labels for statistics analysis variables defined in parameter ANALYSISVARS. |
groupbyvars |
Specifies the variables whose values define the subgroup combinations for the analysis. The variables can be divided by statements inside of ( and ) to represent different levels of subgroup. |
statslist |
Specifies a list of summary statistics to be produced. |
statsinrowsyn |
Place resulting descriptive statistics in rows or columns. |
analysisvardps |
Base precision of descriptive statistics prior to incorporating STATSDPS details. |
statsdps |
List of additional statistic-specific precision values to add to ANALYSISVARDPS. |
codedecodevarpairs |
Specifies code and decode variable pairs. Those variables should be in parameter GROUPBYVARSNUMER. One variable in the pair will contain the code, which is used in counting and ordering, and the other will contain decode, which is used for presentation. |
varcodelistpairs |
List of code/decode pairs of variables. |
codelistnames |
List of decodes for use with decoding code/decode pairs. |
totalforvar |
Variable for which overall totals are required within all other grouped class variables. |
totalid |
Value(s) used to populate the variable(s) specified in totalforvar. |
totaldecode |
Value(s) used to populate the variable(s) of the decode variable(s) of the totalforvar. |
A data frame based on the incoming data frame but collapsed by groups with descriptive statistics added.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir"); dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate( TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) ru_sumstats(G_POPDATA, analysisvars=c("AGE","TRTDURD"), groupbyvars=c("STUDYID","TRT01AN"), codedecodevarpairs=c("TRT01AN", "TRT01A"), totalforvar="TRT01AN", totalid=99, totaldecode="Total", statsinrowsyn = "Y", analysisvardps=list("AGE"=1,"TRTDURD"=2), statslist=c("n", "mean", "median", "sd", "min", "max")) %>% head(10)library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir"); dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate( TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) ru_sumstats(G_POPDATA, analysisvars=c("AGE","TRTDURD"), groupbyvars=c("STUDYID","TRT01AN"), codedecodevarpairs=c("TRT01AN", "TRT01A"), totalforvar="TRT01AN", totalid=99, totaldecode="Total", statsinrowsyn = "Y", analysisvardps=list("AGE"=1,"TRTDURD"=2), statslist=c("n", "mean", "median", "sd", "min", "max")) %>% head(10)
Pass in a data set and identify the columns for reporting to have estimated relative column width returned.
ru_width_rtf(dsetin, varsin = list(), widths = list(), type = "PCT")ru_width_rtf(dsetin, varsin = list(), widths = list(), type = "PCT")
dsetin |
A dataframe containing columns for reporting. |
varsin |
A vector of variables on the reporting dataframe that will be displayed in the output. |
widths |
Provide a set of default widths for some or all variables as desired. (These will be used.) |
type |
Specify the type of width to be computed and returned. (Currently supports PCT, which refers to relative widths not percentages.) |
A list of widths of the same size as the list specified by varsin.
Yongwei Wang, [email protected]
Chris Rook, [email protected]
library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir"); dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate( TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) adae <- rfenv$adamdata$adae.rda() %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) aesum_p <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) %>% dplyr::mutate(ord1=ifelse(tt_summarylevel==0,0,1)) %>% dplyr::rename(ord2=tt_summarylevel) %>% dplyr::arrange(ord1,AEBODSYS,ord2,AEDECOD) %>% dplyr::select(-c(starts_with('tt_p'),starts_with('ord'))) %>% repfun::ru_addpage(grpvars=c('AEBODSYS'),rowsprbdy=35,nosplitvars=TRUE) widths1 <- repfun::ru_width_rtf(aesum_p, c('AEBODSYS','AEDECOD','tt_ac01','tt_ac02','tt_ac03','tt_ac99')) print(widths1) widths2 <- repfun::ru_width_rtf(aesum_p, c('AEBODSYS','AEDECOD','tt_ac01','tt_ac02','tt_ac03','tt_ac99'), list('AEBODSYS'=35, 'AEDECOD'=30)) print(widths2)library(repfun) library(dplyr) datdir <- file.path(gsub("\\","/",tempdir(),fixed=TRUE),"datdir"); dir.create(datdir,showWarnings=FALSE) repfun::copydata(datdir) rfenv <- repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_DICTION=NULL, R_OTHERDATA=NULL, R_INPUTDATA=NULL, R_RAWDATA=NULL, R_SDTMDATA=NULL, R_ADAMDATA=datdir, RetEnv=TRUE) G_POPDATA <- rfenv$G_POPDATA %>% dplyr::mutate( TRT01AN=ifelse(TRT01A=='Placebo',1, ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) adae <- rfenv$adamdata$adae.rda() %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) aesum_p <- repfun::ru_freq(adae, dsetindenom=G_POPDATA, countdistinctvars=c('STUDYID','USUBJID'), groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), anyeventvars = c('AEBODSYS','AEDECOD'), anyeventvalues = c('ANY EVENT','ANY EVENT'), groupbyvarsdenom=c('TRT01AN'), resultstyle="NUMERPCT", totalforvar=c('TRT01AN'), totalid=99, totaldecode='Total', codedecodevarpairs=c("TRT01AN", "TRT01A"), varcodelistpairs=c(""), codelistnames=list(), resultpctdps=0) %>% repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", acrossvarlabel="TRT01A", acrossvarprefix=c("tt_ac", "tt_p")) %>% dplyr::mutate(ord1=ifelse(tt_summarylevel==0,0,1)) %>% dplyr::rename(ord2=tt_summarylevel) %>% dplyr::arrange(ord1,AEBODSYS,ord2,AEDECOD) %>% dplyr::select(-c(starts_with('tt_p'),starts_with('ord'))) %>% repfun::ru_addpage(grpvars=c('AEBODSYS'),rowsprbdy=35,nosplitvars=TRUE) widths1 <- repfun::ru_width_rtf(aesum_p, c('AEBODSYS','AEDECOD','tt_ac01','tt_ac02','tt_ac03','tt_ac99')) print(widths1) widths2 <- repfun::ru_width_rtf(aesum_p, c('AEBODSYS','AEDECOD','tt_ac01','tt_ac02','tt_ac03','tt_ac99'), list('AEBODSYS'=35, 'AEDECOD'=30)) print(widths2)
A SDTM SUPPAE dataset from the CDISC pilot project
suppaesuppae
A data frame with 10 columns:
Study Identifier
Related Domain Abbreviation
Unique Subject Identifier
Identifying Variable
Identifying Variable Value
Qualifier Variable Name
Qualifier Variable Label
Data Value
Origin
Evaluator
Supplemental Adverse Events
A SDTM SUPPAE dataset from the CDISC pilot project
Access the source of the Supplemental Adverse Events dataset.
A SDTM SUPPDM dataset from the CDISC pilot project
suppdmsuppdm
A data frame with 10 columns:
Study Identifier
Related Domain Abbreviation
Unique Subject Identifier
Identifying Variable
Identifying Variable Value
Qualifier Variable Name
Qualifier Variable Label
Data Value
Origin
Evaluator
Supplemental Demography
A SDTM SUPPDM dataset from the CDISC pilot project
Generated dataset.