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, 2019 in Data Analytics by ch
• 3,450 points
3,743 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, 2019 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, 2019 by anonymous
• 33,030 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, 2019 in Data Analytics by Cherukuri
• 33,030 points
12,895 views
+1 vote
2 answers

How to sort a data frame by columns in R?

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

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
1,417 views
0 votes
5 answers

How to remove NA values from a Vector in R?

Hello team, you can use na.omit x <- c(NA, 3, ...READ MORE

answered Dec 9, 2020 in Data Analytics by anonymous
• 82,880 points
191,821 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
1,994 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
1,605 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

edited Jun 9, 2020 by Gitika 892 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
997 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, 2019 in Data Analytics by rajeev
3,870 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, 2019 in Data Analytics by anonymous
• 33,030 points
2,958 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP