[R] Problem with paxckage "survMisc"

Endy BlackEndy pertsou at gmail.com
Tue Mar 17 18:52:42 CET 2015


Hi R users. I would like your help on the following strange, to me,
behavior of the package "survMisc".
I have a simple routine, the following:
 proc<-function(){
  rm(list=ls())
  library(survMisc)
  d<-read.table("C:\\Program
Files\\R\\Data\\Survival\\HosmLem.txt",fill=TRUE,header=TRUE)
  d4<-as.factor(d[,4])
  s<-survfit(Surv(d[,2], d[,5])~d4)
  ctest<-comp(s)$tests
  print(ctest)
}
When I run it as a routine I am  getting the following message:
Error in Surv(d[, 2], d[, 5]) : object 'd' not found
When I run it command-by-command the program works OK.
Any suggestion what it is going wrong?

The first six lines of the data used are

 id Time Age Drug Censor    entdate    enddate
1  1    5  46    0      1 05/15/1990 10/14/1990
2  2    6  35    1      0 09/19/1989 03/20/1990
3  3    8  30    1      1 04/21/1991 12/20/1991
4  4    3  30    1      1 01/03/1991 04/04/1991
5  5   22  36    0      1 09/18/1989 07/19/1991
6  6    1  32    1      0 03/18/1991 04/17/1991

The full data set can be obtained using the command
 d<-read.table("http://www.ats.ucla.edu/stat/r/examples/asa/hmohiv.csv",
sep=",", header = TRUE)

Many thanks
Endy

	[[alternative HTML version deleted]]



More information about the R-help mailing list