How to sort data according to column values in R

0 votes

Hi team,

I have one Dataframe in R. I want to sort the data according to column values. How can I do that?

Oct 30, 2020 in Data Analytics by akhtar
• 38,260 points
583 views

1 answer to this question.

0 votes

Hi@akhtar,

You can sort the rows of a Dataframe according to column values. You can use the order() function. The order() function takes one or more vectors as arguments and returns an integer vector indicating the order of the vectors.

# Sort the pirates dataframe by height
pirates <- pirates[order(pirates$height),]
answered Oct 30, 2020 by MD
• 95,460 points

Related Questions In Data Analytics

+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,767 views
0 votes
1 answer

How to replace all occurrences of a character in a character column in a data frame in R

If you used sub() to replace the ...READ MORE

answered Jun 29, 2019 in Data Analytics by anonymous
• 33,030 points
17,898 views
0 votes
2 answers

In data frame how to spilt strings into values?

You can do this using dplyr and ...READ MORE

answered Dec 5, 2018 in Data Analytics by Kalgi
• 52,350 points
1,051 views
0 votes
1 answer
+10 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 9, 2018 in Data Analytics by Abhi
• 3,720 points
1,577 views
+1 vote
1 answer

Error saying "vector size cannot be NA" when using R with data mining

You can use the removesparseterm function.  Removes sparse ...READ MORE

answered Nov 15, 2018 in Data Analytics by Maverick
• 10,840 points
4,769 views
+1 vote
2 answers
0 votes
1 answer

Trying to find frequent itemsets of a data set using arules package

Try replacing ID <- c("A123","A123","A123","A123","B456","B456","B456") item <- c("bread", "butter", "milk", ...READ MORE

answered Nov 15, 2018 in Data Analytics by Maverick
• 10,840 points
782 views
0 votes
1 answer
0 votes
1 answer

How to add a new column to a Dataframe in R?

Hi@akhtar, You can add new columns to a ...READ MORE

answered Oct 30, 2020 in Data Analytics by MD
• 95,460 points
698 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