I don't use coxphf, but it is generally a bad idea to reference variables via multiple environments (e.g. global and the data= argument in this case) directly from within a formula. Just use FAM138A.chr wherever you have used test[,6] and it should work. -- Sent from my phone. Please excuse my brevity.
On February 9, 2018 8:43:03 PM PST, "Ding, Yuan Chun" <ycd...@coh.org> wrote: >Hi R Users, > >I am very frustrated with the following code. Please do me a favor to >run it. > >after reading into the test data set (I also pasted the data set >below), the first line of code for "res_coxphf" did not work and >generated the error code below. but the other three line worked well. >the second line for "res_coxphf2" should be the same as the first line; >I need to run more than 100 variables in a loop, so I want to do test[, >i], that is why I want to use the first line. > >however, the fourth line for "res_coxphf_cnaRate " also worked well >after I added one variable "cna.rate" to first line. Can you run them >and tell me why the first line does not run correctly? > >please install coxphf package if you do not have it installed. > >Thank you very much!!! > >Ding > >test<-read.csv("data_coxphf.csv", head=T) >res_coxphf <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) >~test[, 6], data=test) >res_coxphf2 <- coxphf(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) >~ test$FAM138A.chr1, data=test) > >res_coxph <- coxph(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~ >test[, 6], data=test) >res_coxphf_cnaRate <- coxphf(formula=Surv(RFS_days2, >OV_Had_a_Recurrence_CODE) ~ test[, 6]+ cna.rate, data=test) > > >> test<-read.csv("data_coxphf.csv", head=T) >> res_coxphf <- coxphf(formula=Surv(RFS_days2, >OV_Had_a_Recurrence_CODE) ~ test[, 6], data=test) >Error in mm1[, !colInter, drop = FALSE] : > (subscript) logical subscript too long >> res_coxph <- coxph(formula=Surv(RFS_days2, OV_Had_a_Recurrence_CODE) >~ test[, 6], data=test) >> res_coxphf_cnaRate <- coxphf(formula=Surv(RFS_days2, >OV_Had_a_Recurrence_CODE) ~ test[, 6]+ cna.rate, data=test) >> res_coxphf2 <- coxphf(formula=Surv(RFS_days2, >OV_Had_a_Recurrence_CODE) ~ test$FAM138A.chr1, data=test) >> > > > >id cna.rate RFS_days2 OV_Had_a_Recurrence_CODE >DDX11L1.chr1 FAM138A.chr1 FAM138F.chr1 >sn1 150 560 1 0 0 0 >sn10 216 581 1 0 0 0 >sn11 191 455 1 0 0 0 >sn12 135 118 1 0 0 0 >sn13 199 2550 0 0 0 0 >sn14 312 477 1 0 0 0 >sn15 260 216 1 0 0 0 >sn16 400 1056 1 0 0 0 >sn17 350 398 1 1 1 1 >sn18 324 583 1 0 0 0 >sn19 174 136 1 0 0 0 >sn20 262 98 1 0 0 0 >sn21 172 516 1 0 0 0 >sn22 490 1439 1 0 0 0 >sn23 165 365 1 0 0 0 >sn24 185 168 1 0 0 0 >sn25 396 1663 1 0 0 0 >sn26 240 299 1 0 0 0 >sn27 114 2917 0 0 0 0 >sn28 128 50 1 0 0 0 >sn29 190 654 1 0 0 0 >sn3 435 429 1 0 0 0 >sn30 268 31 1 0 0 0 >sn31 175 3407 0 0 0 0 >sn32 248 277 1 0 0 0 >sn33 116 306 1 0 0 0 >sn34 122 52 1 0 0 0 >sn35 222 77 1 0 0 0 >sn36 414 242 1 0 0 0 >sn37 300 1034 1 1 1 1 >sn38 268 3298 0 0 0 0 >sn4 556 2424 0 0 0 0 >sn40 274 201 1 0 0 0 >sn41 267 268 1 0 0 0 >sn42 325 147 1 0 0 0 >sn43 323 2611 0 0 0 0 >sn44 115 573 1 0 0 0 >sn45 265 215 1 0 0 0 >sn48 129 259 1 0 0 0 >sn5 114 183 1 0 0 0 >sn51 183 219 1 0 0 0 >sn52 314 271 1 0 0 0 >sn53 465 2071 0 0 0 0 >sn54 207 44 1 0 0 0 >sn55 321 347 1 0 0 0 >sn56 217 1257 0 0 0 0 >sn57 209 262 1 0 0 0 >sn58 227 1811 0 0 0 0 >sn59 130 463 1 0 0 0 >sn6 320 306 1 0 0 0 >sn60 136 456 1 0 0 0 >sn62 208 48 1 0 0 0 >sn63 253 452 1 0 0 0 >sn64 326 282 1 0 0 0 >sn67 260 229 1 0 0 0 >sn68 329 661 0 0 0 0 >sn69 478 44 1 0 0 0 >sn7 263 582 1 0 0 0 >sn70 309 741 1 0 0 0 >sn8 223 1070 0 0 0 0 >sn9 211 216 1 0 0 0 > > >--------------------------------------------------------------------- >-SECURITY/CONFIDENTIALITY WARNING- >This message (and any attachments) are intended solely ...{{dropped:28}} ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.