progRcontent <- function(template) {
##if (template == "DST01") {
content<-
"###Import data
ADSL1 <- read_sas(paste0(\"Studies/\",study,\"/data/ADAM/adsl.sas7bdat\"))
###USe filter
fff <- filters(ADSL1,ADAE1,FilterL)
ADSL <- fff[[1]]
###Get report
## @knitr answer
cat(fff[[3]])
cat(\" \")
####summary table from TERN here ? `
date() "
## }
return (content);
}
############create R programs (Rmd file)##############
create_R_program <- function(progPath,prog_name,progRcontent) {
###check if prog exist###
if (!file.exists(paste0(progPath,prog_name))) {
###get progRcontent depending on TEMPLATE
progRcontent<- progRcontent(template)
Rprog <- file(paste0(progPath,prog_name,".R"))
writeLines(progRcontent, Rprog)
close(Rprog)
progMessage<-paste0("Program ",prog_name," has been created")
####Update database ####
con <- dbConnect(RSQLite::SQLite(), paste0("Studies/",study,"/",study))
request <- paste0("UPDATE ",studyl," SET ",
"Action = 'PROG_OK' , ",
"See = 'See' ",
"WHERE `Program ID` = '", prog_name,"'")
res <- unname(dbSendQuery(con,request))
dbClearResult(res)
dbDisconnect(con)
}
else{
progMessage<-paste0("Program ",prog_name," already exist")
}
return(progMessage)
}
###########Create all programs######################
create_all_R_program <- function(progPath,vect_prog_name) {
for (value in vect_prog_name) {
create_R_program(progPath,value,"test")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.