首页 > 解决方案 > R中的游泳者生存图

问题描述

这是我从datapasta获得的数据集:

data.frame(stringsAsFactors = FALSE,patient_ID = c("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"),Time = c(1596,1514,356,2085,1921,318,83,328,815,1854,159,240,821,720,2315,1800,99,205,177)

我正在尝试获取此数据的游泳者图。我输入了以下内容:

H_N_outcomes_first20$Time <- as.numeric(H_N_outcomes_first20$Time)
H_N_outcomes_first20$patient_ID <- as.character(H_N_outcomes_first20$patient_ID)
library(swimplot)
swimmer_plot(df=H_N_outcomes_first20, id="patient_ID", end= "Time", fill='lightblue', width=0.85)

我收到以下错误消息:

Error in model.frame.default(formula = df[, end] ~ df[, id]) :invalid type (list) for variable 'df[, end]'

https://cran.r-project.org/web/packages/swimplot/swimplot.pdf

标签: r

解决方案


推荐阅读