-1

How do I convert a list of survival times for patients in days to months in R? I would like to perform the survival analysis such as KM curve using months instead of days.

The raw dataset comes in days. For example, Patient 1 - 500, Patient 2 - 450, Patient 3 - 600 etc. There are no units (only numerals) and similarly I would like numerals in months.

Thanks in advance for your help.

user2310
  • 31
  • 1
  • 5
  • 1
    Since you don't have start or end dates, just days as an integer why don't you divide it by the average days per month? – LMc Jan 29 '21 at 01:27
  • Please show first few lines of the data that you have and show corresponding expected output for it to make it clear what you want. – Ronak Shah Jan 29 '21 at 02:00

1 Answers1

2
# load package
library(dplyr)

# example dataframe
patient = c(1,2,3)
days = c(500, 450, 600)
df <- as.data.frame(cbind(patient, days))

# calculate month
df <- df %>% 
  mutate(month = round(days/30.417, digit=0))

# show dataframe
View(df)
Dharman
  • 30,962
  • 25
  • 85
  • 135
TarJae
  • 72,363
  • 6
  • 19
  • 66
  • I think the code is clear. The user asks to calculate survival in months instead of days. As LMc suggests the solution is to divide by the average day by month. I provide a code for the days 500, 450 and 600. The code is commented and should be clear. – TarJae Jan 29 '21 at 13:58