0
0
R Programmingprogramming~20 mins

Descriptive statistics in R Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Descriptive Statistics Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Calculate the mean and median of a numeric vector
What is the output of this R code that calculates the mean and median of the vector c(2, 4, 6, 8, 10)?
R Programming
x <- c(2, 4, 6, 8, 10)
mean_x <- mean(x)
median_x <- median(x)
c(mean_x, median_x)
A[1] 5 5
B[1] 6 5
C[1] 5 6
D[1] 6 6
Attempts:
2 left
💡 Hint
Recall that mean is the average and median is the middle value when sorted.
data_output
intermediate
2:00remaining
Count the number of unique values in a factor
Given the factor f <- factor(c('apple', 'banana', 'apple', 'orange', 'banana', 'banana')), what is the output of length(levels(f))?
R Programming
f <- factor(c('apple', 'banana', 'apple', 'orange', 'banana', 'banana'))
length(levels(f))
A1
B2
C3
D6
Attempts:
2 left
💡 Hint
Levels represent unique categories in a factor.
visualization
advanced
2:30remaining
Interpret a boxplot of numeric data
What does the boxplot of the numeric vector c(1, 2, 2, 3, 4, 5, 6, 7, 8, 20) show about the data distribution?
R Programming
x <- c(1, 2, 2, 3, 4, 5, 6, 7, 8, 20)
boxplot(x, main = 'Boxplot of x')
AThe boxplot shows a left-skewed distribution with an outlier at 1.
BThe boxplot shows a right-skewed distribution with an outlier at 20.
CThe boxplot shows a symmetric distribution with no outliers.
DThe boxplot shows uniform distribution with no outliers.
Attempts:
2 left
💡 Hint
Look for the position of the median and any points outside whiskers.
🧠 Conceptual
advanced
1:30remaining
Understanding variance and standard deviation
Which statement correctly describes the relationship between variance and standard deviation?
AStandard deviation is the square root of variance, both measure data spread.
BVariance is the square root of standard deviation, both measure central tendency.
CVariance and standard deviation are unrelated statistics.
DStandard deviation is always larger than variance.
Attempts:
2 left
💡 Hint
Think about how variance and standard deviation relate mathematically.
🔧 Debug
expert
2:00remaining
Identify the error in calculating the mode
What error does this R code produce when trying to calculate the mode of vector v <- c(1, 2, 2, 3, 4) using mode_v <- mode(v)?
R Programming
v <- c(1, 2, 2, 3, 4)
mode_v <- mode(v)
mode_v
AIt returns the storage mode of the vector, not the statistical mode.
BIt raises a syntax error because mode() is not a valid function.
CIt returns the most frequent value correctly.
DIt returns NULL because the vector is numeric.
Attempts:
2 left
💡 Hint
Check what the mode() function returns in R base.