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 in Data Analytics by akhtar
• 33,040 points
28 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 by MD
• 77,940 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
• 32,490 points
494 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 28, 2019 in Data Analytics by anonymous
• 32,490 points
8,854 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 4, 2018 in Data Analytics by Kalgi
• 51,970 points
182 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 8, 2018 in Data Analytics by Abhi
• 3,720 points
223 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,820 points
1,616 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,820 points
122 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 in Data Analytics by MD
• 77,940 points
34 views