I'm new to R and having difficulty figuring out how to issue/write up the command i need. i'm running survival analysis in an experiment with multiple subjects (observing persistence across trials).
Currently, i can get the surv analysis to work for each participant by rewriting the script to read a new file name and adding a # to each tag (i.e my.survfit1, my.survfit2, etc).
Is there anyway to get R to go through the separate data files on its own and to create separate plots rather than overwriting it for each (via saving each plot, or another method?)
here's my current script:
data <- read.csv(file="dataparticipant1.csv",head=TRUE,sep=",")
data
attach(data)
my.surv <- Surv(time1test, earnings)
my.surv
survfit(my.surv ~ 1)
my.fit <- survfit(my.surv ~ 1)
plot(my.fit, main="SurvCurve of participant1", xlab="time", ylab="survival")