Question: How would you write code in R studio for: Step 2: In a new code chunk below the last, write code that will create a

How would you write code in R studio for:

Step 2: In a new code chunk below the last, write code that will create a subset of the data containing just the name, height and weight columns for males that are no more than 48" tall (Southpark fitness data) or no more than 68" tall (your own lab 1 fitness data).

Step 3: Below the last code, write another command that will create a dataframe with just the name, time, sbp, dbp and xbp variables for females at least 9 years old (Southpark fitness data) or at least 19 years old (your own lab 1 fitness data).

Generic structure: newdataset <- subset(parentdataset, cases to retain, select=c(list of variables))

Some examples:

data.l.males <- subset(data.l, gender=="m") #Just the males.

data.l.a8 <- subset(data.l, age==8) #Just the 8 year olds.

data.l.h48 <- subset(data.l, height >= 48) #Just the subjects at least 48" tall ( >= means "greater than or equal to")

data.l.a9m <- subset(data.l, age==9 & gender=="f") #Just the 9 year old females

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!