在R中将数字(天)转换为数字(月)

Convert numeric (days) to numeric (months) in R

如何在 R 中将以天为单位的患者生存时间列表转换为以月为单位的列表?我想用几个月而不是几天来执行 KM 曲线等生存分析。

原始数据集会在几天内出现。例如,患者 1 - 500、患者 2 - 450、患者 3 - 600 等。没有单位(只有数字),同样我想要以月为单位的数字。

在此先感谢您的帮助。

# 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)