Problem 1 . x=c(\"Narinder\",\"Brendan\",\"Jing\",\"Mohammed\",\"Nichola\",\"Oma
ID: 3883732 • Letter: P
Question
Problem 1 . x=c("Narinder","Brendan","Jing","Mohammed","Nichola","Omar","Isaiah","Brian","Shuyu","Chengchao","Sean","Katherine","Eben", "Karl","Maggie")
y=c(66,61, 59, 62, 77, 64, 68, 76, 68, 70, 73, 73, 72, 76, 68)
z=c(6744, 3231, 5682, 7553, 5744, 6442, 5738, 3220, 6249, -512, 5610, 6340, 4800, 3822, 7464)
a) Combine these lists into a data frame with the first column called “names", the second column called “height" and the third column called "saving".
b) Store this data frame in a variable called students_info.
c) Sort the data frame by saving account from highest to lowest.
ANSWER WITH R CODE
Explanation / Answer
R code:
# initialise the columns
names = c("Narinder","Brendan","Jing","Mohammed","Nichola","Omar","Isaiah","Brian","Shuyu","Chengchao","Sean","Katherine","Eben", "Karl","Maggie")
height = c(66,61, 59, 62, 77, 64, 68, 76, 68, 70, 73, 73, 72, 76, 68)
saving = c(6744, 3231, 5682, 7553, 5744, 6442, 5738, 3220, 6249, -512, 5610, 6340, 4800, 3822, 7464)
# create a dataframe with 3 columns
df = data.frame(names, height, saving)
#sort the dataframe according to column saving
df[rev(order(df$saving)),]
Sample Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.