Error in `value[[3L]](cond)`: attempt to apply non-function

D_FOOT1='1.) Only treatment emergent events related to lipids are displayed.',
D_FOOT2='2.) Subjects are only counted once within each body system and preferred term.',
D_TITLE1=paste0('Table 1: Summary of Treatment Emergent Adverse Events'),
# Read ADSL directly, subset and compare with G_POPDATA.
indata %>% dplyr::filter(SAFFL=='Y') -> C_POPDATA

'1.) Only treatment emergent events related to lipids are displayed.'
'2.) Subjects are only counted once within each body system and preferred term.'
'Table 1: Summary of Treatment Emergent Adverse Events'

repfun::rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_ADAMDATA=".")
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 <- inadae %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) %>% dplyr::filter(TRTEMFL=='Y')
splitchar="~") %>% dplyr::select(STUDYID, USUBJID, TRT01AN, TRT01A, AEBODSYS, AEDECOD) %>%
dplyr::arrange(STUDYID, USUBJID, TRT01AN, TRT01A, AEBODSYS, AEDECOD)
qcbign <- G_POPDATA %>% dplyr::group_by(TRT01AN,TRT01A) %>% dplyr::summarize(DENOMCNT=n()) %>% dplyr::ungroup() %>%
dplyr::select(TRT01AN,TRT01A,DENOMCNT) %>% dplyr::mutate(TRT01A=paste0(TRT01A,'~(N=',as.character(DENOMCNT),')')) %>% dplyr::select(-DENOMCNT)
qcadae <- adae %>% select(-c('TRT01A')) %>% left_join(qcbign, by=c("TRT01AN"))
attr(G_POPDATA$TRT01AN,"label") <- 'Actual Treatment for Period 01'
qcadae <- as.data.frame(qcadae) %>% select(STUDYID, USUBJID, TRT01AN, TRT01A, AEBODSYS, AEDECOD)
qcadae <- repfun::ru_labels(qcadae,varlabels=lapply(addbign, attr, "label"))
qcadae <- qcadae %>% dplyr::arrange(STUDYID, USUBJID, TRT01AN, TRT01A, AEBODSYS, AEDECOD)

test_that("adding page numbers works", {
# Setup reporting environment and read in AE data.
rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_ADAMDATA=".")
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)')) -> G_POPDATA
adae <- rfenv$adamdata$adae.rda() %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A'))
anyeventvalues = c('ANY EVENT','ANY EVENT'),
qc[((p-1)*30 < qc$rownum) & (qc$rownum <= p*30),c('PAGEVAR')] <- p