Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to calculate the mean of the numeric vector data.
R Programming
mean_value <- mean([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the function name inside itself instead of the data vector.
Using
sum or median instead of the data vector.✗ Incorrect
The
mean() function calculates the average of the values in the vector data.2fill in blank
mediumComplete the code to calculate the median of the numeric vector values.
R Programming
median_value <- median([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the function name
median inside itself instead of the data vector.Using
mean or length instead of the data vector.✗ Incorrect
The
median() function finds the middle value of the vector values.3fill in blank
hardFix the error in the code to calculate the standard deviation of scores.
R Programming
std_dev <- sd([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the function name
sd instead of the data vector.Using
mean or var instead of the data vector.✗ Incorrect
The
sd() function calculates the standard deviation of the vector scores. You must pass the data vector, not the function name.4fill in blank
hardFill both blanks to create a named list with mean and median of numbers.
R Programming
summary_stats <- list(mean = [1], median = [2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the function names
mean or median without calling them.Using the vector
numbers directly instead of calculating the statistics.✗ Incorrect
Use
mean(numbers) and median(numbers) to calculate the values and assign them to the list.5fill in blank
hardFill all three blanks to create a data frame with mean, median, and standard deviation of data_vec.
R Programming
stats_df <- data.frame( Mean = [1], Median = [2], SD = [3] )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the vector
data_vec directly instead of calculating statistics.Mixing up the order of mean, median, and standard deviation.
✗ Incorrect
Calculate mean, median, and standard deviation of
data_vec and assign them to the data frame columns.