• Register
0 votes
116 views

Problem :

I am stuck because of following weired error
error in sort.list(y) : 'x' must be atomic for 'sort.list' have you called 'sort' on a list?
6 5 3
6,930 points

2 Answers

0 votes

Solution :

The error is occurring may be because the table calls sort.list, which should have an atomic vector as its input.

Using unlist:

e.g

cc3 <- as.data.frame(table(unlist(cc2)))

Here unlist will extract elements from their list containers. So unlist(cc2) will return the vector, which works directly with table.

So your issue will get resolved.
9 7 4
38,600 points
0 votes

Solution:

From the output of str(cc2), the variable within of the data.table, V1, is itself a list. This imply that cc2 is a nested list of length 1. The error is happening since table calls sort.list, which necessary an atomic vector as input.

Attempt employing unlist:

cc3 <- as.data.frame(table(unlist(cc2)))

unlist will extract elements from their list containers. Hence unlist(cc2) will return a vector, which performs directly with table.

I solved it by unlisting cc2 unli <- unlist(cc2) thereafter converted it to df df<-as.data.frame(cc2)

As far as I can view, the issue is that you have a nested dataframe. I can't notify of any solution except unlisting the nested dataframe (converting it to a vector):

tk1_h$profile <- unlist(tk1_h$profile)

Attempt the following R code, which must work

library(survival)
data(veteran)
fit <- survfit(Surv(time, status)~trt, data = veteran)
survminer::ggsurvplot(fit, risk.table = TRUE)

 

10 6 4
31,120 points

Related questions

0 votes
2 answers 226 views
226 views
Problem : I am trying to do data manipulation using R. I am trying to import the file which is having headings and also numbers in the multiple columns. I am trying to divide my values in the one column by the other column and then trying to determine the highest values. But ... below error &ldquo;Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic&rdquo;.
asked Feb 17 mphil 2.3k points
0 votes
2 answers 1.6K views
1.6K views
Problem : Below is my code which is giving me the error. plot(x,y) yx.lm <- lm(y ~ x) lines(x, predict(yx.lm), col="red") Why am I facing following error? Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet
asked Dec 4, 2019 alecxe 7.5k points
0 votes
1 answer 1.4K views
1.4K views
Problem : I am trying to predict probabilities in a dataset by using glmnet but facing following issue cholmod error 'x and/or y have wrong dimensions' at file ../matrixops/cholmod_sdmult.c, line 90
asked Nov 13, 2019 peterlaw 6.9k points
1 vote
1 answer 78 views
78 views
Problem: I have very fundamental knowledge of logistic regression. I am trying to write code on logistic regression. I have done a lot of research on this issue but because of my limited knowledge I am still unable to fix the below error. Error ... (data) stock.direction <- data$Direction training_model=glm(stock.direction~data$lag2,data=data,family=binomial) Please help me in fixing above error.
asked May 26 Martin K 6.6k points
0 votes
2 answers 838 views
838 views
Problem : I am facing below error and I am unable to understand the meaning of the error. All my variable names are correct and there are no typing errors. Does anybody faced this issue before any solution on it? My erroneous code : datNewagg <- aggregate (dataNew, by = ... mean) It gives following error : Error in aggregate.data.frame(datNew, by = list("x", "y", : arguments must have same length
asked Dec 6, 2019 alecxe 7.5k points