Complete the code to create a vector of numbers from 1 to 5 in R.
numbers <- [1](1, 2, 3, 4, 5)
In R, c() combines values into a vector, which is the basic data structure for numbers.
Complete the code to calculate the mean of a numeric vector named 'data' in R.
average <- [1](data)The mean() function calculates the average value of numeric data in R.
Fix the error in the code to subset rows where the 'age' column is greater than 30 in a data frame 'df'.
subset_df <- df[df$[1] > 30, ]
To access a column in a data frame by name, use $ followed by the exact column name without parentheses or brackets.
Fill both blanks to create a new data frame with only rows where 'score' is greater than 80 and select the 'name' and 'score' columns.
high_scores <- df[df$[1] [2] 80, c('name', 'score')]
To filter rows where 'score' is greater than 80, use df$score > 80. Then select columns by name.
Fill all three blanks to create a summary table with the mean of 'height' grouped by 'gender' using the dplyr package.
library(dplyr) summary <- df %>% group_by([1]) %>% summarise([2] = mean([3]))
Use group_by(gender) to group data by gender, then summarise(avg_height = mean(height)) to calculate the average height per group.