Back to Practice
#0126
Create Summary Data Frame in R
EasyR15 min10 XP
Problem
Given vectors group <- c("A","A","B") and score <- c(10,20,5), write R code that creates a data frame with mean score per group.
Why This Matters
Creating clean summary tables is one of the first useful outputs in R.
Examples
Example 1
InputA: 10,20 and B: 5
OutputA mean 15, B mean 5
aggregate applies mean within each group.
Constraints
- Return the requested value exactly.
- Handle the stated edge cases.
- Keep the solution readable.
CodeR
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
InputA: 10,20 and B: 5
ExpectedA mean 15, B mean 5
aggregate applies mean within each group.
Hidden Test Categories
one groupdecimal scoresrenaming output columns