0

I am trying to test the hypothesis that there is no difference in survival between the four groups in the data (kidney), reported on the death times of 863 kidney transplant patients. Where patients can be classified by race and sex into one of four groups.

I am using the code:

library(KMsurv)
data(kidney)
kidney
head(kidney)
str(kidney)

group<- rep(NA, dim(kidney)[1])
group[ kidney$gender==1 & kidney$race==1 ] <- 1
group[ kidney$gender==1 & kidney$race==2 ] <- 2
group[ kidney$gender==2 & kidney$race==1 ] <- 3
group[ kidney$gender==2 & kidney$race==2 ] <- 4

library(survival)
survdiff(Surv(obstime, death)~group, data=kidney)

survdiff(Surv(obstime, death)~race, data=kidney, subset=gender==1)

survdiff(Surv(obstime, death)~race, data=kidney, subset=gender==2)

survdiff(Surv(obstime, death)~race+strata(gender), data=kidney)

but I have not got the data of 863 kidney transplant patients, I got only 119 observation. Is there a mistake in the code I'm using? I'm unable to get any results since I could not get the whole data.

I have tried this code to obtain the data, but I am still having the same issue:

getwd()
kidney<- read.csv("kidneytransplant.csv")
head(Kidney)
str(Kidney)
camille
  • 16,432
  • 18
  • 38
  • 60
Heidi
  • 25
  • 5
  • According to `?KMsurv::kidney` or `dim(kidney)`, the kidney data frame that you loaded with `data(kidney)` has 119 rows and 3 columns. If you defined your own `kidney` variable, make sure you don't overwrite it by calling `data(kidney)` after loading your kidney data. – user12728748 Mar 15 '20 at 18:39
  • you don't need to create `group`, you can do `survdiff(Surv(obstime, death) ~ gender + race, data=kidney)`, but if you are, I would suggest adding it as a variable to your data frame instead of a separate object – rawr Mar 15 '20 at 19:38

0 Answers0