(R STUDIO) CREATE A VECTOR USING WEIGHTS IN ORDER FROM YOUNGEST PERSON TO OLDEST
ID: 3071673 • Letter: #
Question
(R STUDIO) CREATE A VECTOR USING WEIGHTS IN ORDER FROM YOUNGEST PERSON TO OLDEST
I need to use R studio and provide code that will create a vector from a family.csv file using the weights, but arrange them from youngest to oldest. The only functions I've learned so far are: filter(), arrange(), select(), slice(), mutate(), group_by(), summarise(), dbinom(), c(), sample(), rep(), replicate(), length(), class(), is.na(), mean(), median(), and sample(). I need an answer using only the functions I've learned.
X firstName gender age height weight m 77 f 33 m 79 m 47 f 27 f 33 m 67 f 52 m 59 m 27 f 55 m 24 m 46 f 48 bmi overWt 70 175 25.16239 TRUE 64125 21.50106 FALSE 73 185 24.45884 FALSE 67 156 24.48414 FALSE 64105 18.06089 FALSE 68 190 28.94981 TRUE 68 185 28.18797TRUE 65 124 20.67783 FALSE 68 175 26.66430 TRUE 71 215 30.04911 TRUE 67 166 26.05364 TRUE 66 140 22.64384 FALSE 66 150 24.26126 FALSE 62 125 22.91060 FALSE Tom May Joe Sue Liz Jon Tim Tom Ann Dan Art Zoe 10 10 12 12 13 13 14 14Explanation / Answer
ok , these all syntaxes are from the dplyr package
you can simply run the below command in R to get the result
assuming that the data is in dataframe family
family.vector <- family %>%
arrange(age) %>% ## arrange data by age in ascending order
select(weight) %>% ## only select weight variable
as.vector() ## convert it to a vector and store in family.vector
Hope this helps !!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.