• Register
0 votes
182 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

Please log in or register to answer this question.

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 653 views
653 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, 2020 mphil 2.3k points
0 votes
1 answer 11 views
11 views
Problem: i tried alot to fix it but it didnt work , can anybody explain why not ? Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
2 answers 2.9K views
2.9K 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 18 views
18 views
Problem: Hey everyone, any Help: cholmod error 'x and/or y have wrong dimensions' at file ../matrixops/cholmod_sdmult.c, line 90
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2.2K views
2.2K 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 314 views
314 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, 2020 Martin K 6.6k points
0 votes
1 answer 4 views
4 views
Problem: Any solution for this error: Error in aggregate.data.frame(as.data.frame(x), ...) : arguments must have same length
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
2 answers 1.8K views
1.8K 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
0 votes
1 answer 41 views
41 views
Problem: comparison (1) is possible only for atomic and list types.
asked Feb 22 Dan phillip 4.7k points
0 votes
1 answer 35 views
35 views
Problem: error in sort(y) : argument "y" is missing, with no default.
asked Feb 16 charles mathews 5.5k points