Which command correctly uses pipes to compute the mean of the variable age in bfi?
- NA
- FALSE: This command incorrectly attempts to access
agefrom the result ofmean()called onbfi. - FALSE: This command incorrectly attempts to compute the mean of
agedirectly on thebfidata frame using the base R pipe operator|>. - TRUE: This command correctly uses the base R pipe operator
|>to passbfi$ageto themean()function. - TRUE: This command correctly uses the pipe operator
%>%to extractagefrombfiand then computes the mean.
Which use of the placeholder . is valid when the data are not the first argument?
- FALSE: The placeholder is incorrectly used after the function call.
- FALSE: The placeholder is incorrectly used as a function.
- FALSE: The placeholder is incorrectly used as the first argument.
- FALSE: This use of the placeholder is the correct syntax for passing the data argument in a pipe, but it will not work with the base R pipe operator.
- TRUE: This use of the placeholder is the correct syntax for passing the data argument in a pipe.
Using %>%, write (in one line) how you would compute the squared variance of the column bmi inside health, assuming bmi exists.
The correct code is health$bmi %>% var() %>% sqrt().
Using a pipeline, calculate the mean of the agree variable for participants who are older than 30 years. Use the WebR to write your code and insert the result in the box, rounding to two decimal places.
Round your answer to two decimal places.
The correct pipeline code to calculate the mean of the agree variable for participants older than 30 years is:
bfi %>% filter(age>30) %>% select(agree) %>% unlist() %>% mean()
After rounding, we get 4.84.