R: Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...)

0 votes

Error with sort function as below.

> l = list(1,2,3,4)
> sort(l,decreasing = T)
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 
  'x' must be atomic
Oct 14 in Data Analytics by ch
• 3,290 points
34 views

2 answers to this question.

0 votes
hey @ch,

The sort function is used for vectors or an atomic vector. In your case, the argument passed to the list function is not atomic list.
Sort function would not throw an error if l = list(1:4) and use sort(l[[1]])
answered Oct 14 by mohan
0 votes

Use unlist function to convert the list ta a vector and then perform sort function.

sort(unlist(l),decreasing = T)
answered Oct 14 by anonymous
• 31,840 points

Related Questions In Data Analytics

0 votes
1 answer

Error in unique.default(x, nmax = nmax) : unique() applies only to vectors in R

This error is displayed if you used ...READ MORE

answered Oct 30 in Data Analytics by Cherukuri
• 31,840 points
109 views
0 votes
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21 in Data Analytics by anonymous
• 31,840 points
152 views
0 votes
4 answers

How to remove NA values from a Vector in R?

You can try na.omit() or na.exclude() too. ...READ MORE

answered Jul 31 in Data Analytics by anonymous
• 31,840 points
8,691 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
116 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
161 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points
87 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
106 views
0 votes
1 answer

How to convert a continuous variable to discrete variable and vice versa in R?

Discretize function convert a continuous variable into ...READ MORE

answered Nov 4 in Data Analytics by rajeev
69 views
0 votes
1 answer

List all dataframes in R session.

Try this. for(x in ls()){   if("data.frame" %in% ...READ MORE

answered Nov 4 in Data Analytics by anonymous
• 31,840 points
29 views