Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in sort.list(y) : 'x' must be atomic for 'sort.list' #387

Closed
KohSoonho opened this issue May 11, 2019 · 3 comments
Closed

Error in sort.list(y) : 'x' must be atomic for 'sort.list' #387

KohSoonho opened this issue May 11, 2019 · 3 comments

Comments

@KohSoonho
Copy link

KohSoonho commented May 11, 2019

Hi, I'm using a follow script

## creating simulation data
control_mutant <- list(rate = 0.03, rep = 25, treat = "control", genotype = "mutant")
treat_mutant <- list(rate = 0.03 * 0.55, rep = 125, treat = "treat", genotype = "mutant")
control_wild <- list(rate = 0.03 * 0.2, rep = 125, treat = "control", genotype = "wild")
treat_wild <- list(rate = 0.03 * 0.55 * 0.2, rep = 25, treat = "treat", genotype = "wild")

lst <- list(control_mutant, treat_mutant, control_wild, treat_wild)

# set seed
set.seed(4321)

# make simulated df
simulated_df <- map(lst, ~ tibble(time = rexp(.$rep, rate = .$rate),  
                                  status = 1,                         # there is no censoring
                                  treat = .$treat, 
                                  genotype = .$genotype)) %>%   # making list of tibble
                  bind_rows()   # combine to one table

## plot K-M curve 
ggsurvplot(surv_fit(Surv(time, status) ~ treat, data = simulated_df))

and it's fail with
sort.list(y) でエラー: 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

It looks like No.73 issue, but I cannot solve this error.
Can you advise me for this error?

@kassambara
Copy link
Owner

The problem is that your factor variable treat has a level of the same name. I'm modifying the code to fix this

kassambara added a commit that referenced this issue May 11, 2019
@kassambara
Copy link
Owner

Fixed now, thanks.

You can either change the name of your factor variable to treatment instead of treat or install the latest developmental version of survminer: devtools::install_github("kassambara/survminer")

@KohSoonho
Copy link
Author

Thank you for your fixing. I confirmed this code can run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants