[R] extracting from data.frames for survival analysis
Gerrit Eichner
Gerrit.Eichner at math.uni-giessen.de
Thu Jan 26 12:58:39 CET 2012
Hi, Philip,
counter-questions:
1. Which/where is the grouping variable for the test of differences in
survival?
2. Assume the grouping variable is Gend in B27.vec. Then, why aren't you
using
survdiff( Surv( AgeOn, UV) ~ Gend, rho = 0, data = B27.vec)
?
Hth -- Gerrit
On Thu, 26 Jan 2012, Philip Robinson wrote:
> Hi,
>
> I have a data frame:
>
>> class(B27.vec)
> [1] "data.frame"
>
>> head(B27.vec)
>
> AGE Gend B27 AgeOn DD uveitis psoriasis IBD CD UC InI BASDAI BASFI Smok UV
> 1 57 1 1 19 38 2 1 1 1 1 1 5.40 8.08 NA 1
> 2 35 1 1 33 2 2 1 1 1 1 1 1.69 2.28 NA 1
> 3 49 2 1 40 9 1 1 1 1 1 1 8.30 9.40 NA 0
> 4 32 1 1 21 11 1 1 1 1 1 1 5.10 9.10 NA 0
> 5 31 1 1 24 7 1 1 1 1 1 1 6.63 6.52 NA 0
> 6 27 1 1 23 4 1 2 1 1 1 1 7.19 6.51 NA 0
>
> I am trying to perform survival analysis but continually get errors
> when extracting from this data.frame:
>
> attempt 1:
>> X <- Surv(B27.vec$AgeOn,B27.vec$UV)
>> survdiff(X,rho=0,data=uvf)
> Error in x$terms : $ operator is invalid for atomic vectors
>
> attempt 2:
>> X <- Surv(B27.vec[,4],B27.vec[,15])
>> survdiff(X,rho=0,data=uvf)
> Error in x$terms : $ operator is invalid for atomic vector
>
> attempt 3:
>> AO <- B27.vec[["AgeOn", exact = TRUE]]
>> UV <- B27.vec[["UV",exact=TRUE]]
>> X <- Surv(AO,UV)
>> survdiff(X,rho=0,data=uvf)
> Error in x$terms : $ operator is invalid for atomic vectors
>
> I have read ?data.frame & extract.data.frame but I cannot understand
> how I might structure this differently so it extracts the required
> columns from this dataframe. For the second 2 attempts I am not using
> the $ term. Sorry if this seems basic but cannot understand why
> attempt 1 or 2 doesn't work.
>
> thanks
> Philip
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list