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,220 points
112 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,320 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,010 points
745 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,010 points
15,052 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,370 points
288 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
412 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
2,550 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
214 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,320 points
201 views