How to arrange a data set in ascending order based on a variable?

0 votes
I'm sorry i'm a noob at R. I've just started learning R for work purpose. I have a dataset which consists of movie name, movie id and the views its got. So three columns - movie_id, movie_name, views. I need to arrange this data set in ascending order of the views, i.e. the movie that has got the least views on the top and the one that's got the maximum views, at the end.

How do I achieve this in R?
Nov 27, 2018 in Data Analytics by Ali
• 10,380 points
23 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hey @Ali, you can use the dplyr package of R for this purpose. dplyr is mainly used for data manipulation. You can try something like this:

install.packages('dplyr')
library(dplyr)
data <- read.csv("file_path.csv")
name = arrange(nameofdataframe, variable)
view(name)

where variable is the variable which will be used to arrange it in ascending order.

answered Nov 27, 2018 by Maverick
• 10,020 points
0 votes

In your case it'll be,

orderedviews = arrange(movie_views, views)
view(orderedviews)
answered Nov 27, 2018 by Kalgi
• 36,220 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer

How to create dummy variables based on a categorical variable of lists in R?

You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE

answered Apr 13, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
338 views
0 votes
1 answer

How to replace a value in a data frame based on a conditional 'If' statement?

It's easier to convert alpha to characters ...READ MORE

answered Jun 6, 2018 in Data Analytics by darklord
• 6,140 points
27 views
0 votes
1 answer

How to change the value of a variable using R programming in a data frame?

Try this: df$symbol <- as.character(df$symbol) df$symbol[df$symb ...READ MORE

answered Jan 11 in Data Analytics by Tyrion anex
• 8,280 points
55 views
0 votes
1 answer

Convert java code to R code

You can rjava package for this purpose. rJava is ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,020 points
182 views
0 votes
1 answer
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,020 points
22 views
0 votes
1 answer

How do I convert data frame to csv file in R?

Hey @Ali, its very simple one line ...READ MORE

answered Nov 21, 2018 in Data Analytics by Maverick
• 10,020 points
30 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.