[R] Summarising Data for Forrest Plots
Polwart Calum (County Durham and Darlington NHS Foundation Trust)
calum.polwart at nhs.net
Thu Jul 30 22:43:00 CEST 2009
>Ah, I think I see what you want. Try this on each pair of exclusive sets:
>
n_total<-dim(mydataset)[1]
under65<-mydataset$age <= 65
n_under65<-sum(under65)
under65row<-c(sum(mydataset$dose[under65] == "FD"),
sum(mydataset$dose[under65] == "RD"),
sum(mydataset$vitalstatus[under65] == "dead" &
mydataset$dose[under65] == "FD"),
sum(mydataset$vitalstatus[under65] == "dead" &
mydataset$dose[under65] == "RD"))
over65row<-c(sum(mydataset$dose[!under65] == "FD"),
sum(mydataset$dose[!under65] == "RD"),
sum(mydataset$vitalstatus[!under65] == "dead" &
mydataset$dose[!under65] == "FD"),
sum(mydataset$vitalstatus[!under65] == "dead" &
mydataset$dose[!under65] == "RD"))
>
>Then under65row and over65row should be the first two rows of your result.
>Can't test this at the moment, but I don't think it's too far wrong.
Thanks Jim.
Yes it looks like that code should do the job. I was really hoping for a code like "SummariseForSubsetAnalysis(mydataset, by=mydatatset$dose, subsets=c(age, renal, sex, toxicity), event=survival )" which would magically do it for me ;-)
I guess if this is something I start having to do lots I might have to write one.
Surprised one doesn't seem to exist - perhaps the number of variations in what people want would be too complex.
Calum
********************************************************************************************************************
This message may contain confidential information. If yo...{{dropped:21}}
More information about the R-help
mailing list