Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Do the following excercies in R langauge and answers the questions. Exercise 5.2 a. Create and store this data frame as dframe in vour R
Do the following excercies in R langauge and answers the questions.
Exercise 5.2 a. Create and store this data frame as dframe in vour R workspace: person sex uny Stan Francine F Med Steve Roger M High Hayley F Med Klaus M High Low M Med The variables person, sex, and funny should be identical in nature to the variables in the mydata object studied throughout Section 5.2. That is, person should be a character vector, sex should be a factor with levels F and M, and funny should be a factor with levels Low, Med, and High Stan and Francine are 41 years old, Steve is 15, Hayley is 21, and Klaus is 60. Roger is extremely old-1,600 years. Append these data as a new numeric column variable in dframe called age. Use your knowledge of reordering the column variables based on column index positions to overwrite dframe, bringing it in line with mydata. That is, the first column should be person, the second column age, the third column sex, and the fourth column funny Turn your attention to mydata as it was left after you included the age.mon variable in Section 5.2.2. Create a new version of mydata called mydata2 by deleting the age.mon column. Now, combine mydata2 with dframe, naming the resulting object mydataframe. b. c. d. e. f. Write a single line of code that will extract from mydataframe just of any records where the individual is female the names and ages and has a level of funniness equal to Med OR High. Use your knowledge of handling character strings in R to extract all records from mydataframe that correspond to people whose names start with S. Hint: Recall substr from Section 4.2.4 (note that substr can be applied to a vector of multiple character strings) gStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started