So I currently have this code below in a file, pullsec.R
pullsec <- function(session=NULL){
if(is.null(session)) session<-1
stopifnot(is.numeric(session))
paste("Session",1:10)[session]
}
In an .Rnw file, I call on this pullsec.R and choose session number 3 by:
source("pullsec.R")
setsec <- pullsec(3)
which would pull all of the rows where the column Session has data values of "Session 3"
I would like to add another block to pullsec.R that would allow me to pull data for a second column, Sessions where the data in that column is Sessions 1-2, Sessions 3-4, Session 5-6, etc. But I'm not sure how to modify the pullsec block to accept multiple inputs.
I had tried many solutions but no bite. My most naive solution is:
pullsec2 <- function(sessions1=NULL,sessions2=NULL){
if(is.null(sessions1)) sessions1<-1
stopifnot(is.numeric(session1))
paste("Sessions",1:10,"-",1:10)[sessions]
}