Original link:tecdat.cn/?p=14683

Original source:Tuo End number according to the tribe public number

 

expected

Plot survival charts

The actual

Object of type ‘symbol’ is not subsettable

Steps to reproduce the problem

Library (SurvMiner) #> Le charteite Le package: ggplot2 #> Le charteite Le package: Ggpubr #> Warning: Le package 'ggpubr' a ete compile avec la version R 3.4.3 #> Le charset a horse and carriage le package: Magrittr require("survival") #> Le charset a horse and carriage Le package: survival survie <- Surv(time, status) ~ sex fit<- survfit(survie, data = lung) ggsurvplot(fit, data = lung) #> Error: Objet de type 'symbol' non indiA §ableCopy the code

Ggsurvplot () attempts to capture the survival formula Surv(time, status) ~ sex from the object as follows: fit$call$formula.

By splitting the R code, executing fit $Call $formula results in ‘survie’ instead of Surv(time, status) ~ sex. This results in an error message.

Please fit and merge the visualized survival curve as follows:

library(survival)

fit <- survfit(Surv(time, status) ~ sex, data = lung)

ggsurvplot(fit, data = lung)
Copy the code

If you still want to decompose R code, THEN I recommend using the surv_fit() function [in the SurvMiner package], which is an extension of the basic R function with more functionality than survfit()

You can use it as follows:

survie <- Surv(time, status) ~ sex

fit <- surv_fit(survie, data = lung)

ggsurvplot(fit, data = lung)
Copy the code


reference

1. How to solve the problem of SINGULAR FIT in linear mixed model

2. Install the R software package on the UBUNTU VM

3. Run R language commands on the CLI in WINDOWS