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. We pass the vector data as the argument.2fill in blank
mediumComplete the code to calculate the median of the numeric vector values.
R Programming
median_value <- [1](values) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
mean instead of median.Using
sum or min which do not calculate the median.✗ Incorrect
The
median() function returns the middle value of the sorted vector, which is the median.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
Using a variable name that does not exist like
score.Misspelling the variable name.
✗ Incorrect
The variable holding the data is named
scores. Using the correct variable name avoids errors.4fill in blank
hardFill both blanks to create a named list with mean and median of data_vec.
R Programming
stats <- list(mean = [1](data_vec), median = [2](data_vec))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
sum or sd instead of mean or median.Mixing the order of mean and median.
✗ Incorrect
The list contains the mean and median calculated by their respective functions on
data_vec.5fill in blank
hardFill all three blanks to create a named list with mean, median, and standard deviation of nums.
R Programming
summary_stats <- list([1] = [2](nums), median = [3](nums), sd = sd(nums))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
median as the key instead of mean.Mixing up the order of keys and functions.
✗ Incorrect
The list keys and functions are: mean (key and function), median (key and function), and sd (key and function).