• Register
0 votes
149 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 417 views
417 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
2 answers 2.3K views
2.3K 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.9K views
1.9K 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 170 views
170 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
2 answers 1.4K views
1.4K 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 82 views
0 votes
3 answers 689 views
689 views
Problem : I am trying to coerce a list object to type 'double' Please find below my code: a <- structure(list(`X$Days` = c("10", "38", "66", "101", "129", "185", "283", "374")), .Names = "X$Days") Here a is like $`X$Days` [1] ... however the coercing functions are returning me following error: Error: (list) object cannot be coerced to type 'double' Please let me know how can I resolve the issue.
asked Dec 3, 2019 alecxe 7.5k points
0 votes
1 answer 2.9K views
2.9K views
Problem : While I am trying to run the boxcox transformation with the following code urban1 <- subset(ski,urban <= 4,na.rm=TRUE) ski$gender <- as.numeric((as.character(ski$gender)),na.rm=TRUE) urban1 <- as.numeric((as.character(urban1))) a <- (ski$gender*urban1) ... -> boxcar -> boxcar.formula -> lm -> lm.fit Execution halted Please let me know if anyone knows the solution for this error message.
asked Nov 27, 2019 alecxe 7.5k points
1 vote
1 answer 1.8K views
1.8K views
Problem : I want to perform a logistic regression but I am facing following error I am unable to find my mistake. summary(glm(prefmerkel~angst+crisismerkel+leadership+trustworthiness+ideology+pid+agegroups+gender+region,data=gles)) Error in glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, ... In Ops.factor(eta, offset) : -' nicht sinnvoll für Faktoren 3: In Ops.factor(y, mu) : -' nicht sinnvoll für Faktoren
asked Nov 24, 2019 alecxe 7.5k points
0 votes
1 answer 1.2K views
1.2K views
Problem : Suppose I have data.frame a And I am using following code m.fit <- lm(col2 ~ col3 * col4, na.action = na.exclude) Here the col2 has some NA values And col3,col4 have values less than 1. I am getting following error: Error in lm.fit ... because of the NAs. Problem with this warning is interpreted by every google results is pointing towards the NA values. Have I misinterpreted the error ?
asked Nov 22, 2019 peterlaw 6.9k points