Code Studio: Summary Statistics
Practise the base-R summary functions from Practice: Statistical Summary on the built-in swiss dataset.
The program reads the name of a column of swiss (for example Agriculture). Select that column with swiss[[column]], then print, each rounded to 2 decimal places:
- the mean, as
Mean: … - the standard deviation, as
SD: … - the median, as
Median: … - the first and third quartiles from
quantile(v, c(0.25, 0.75)), asQ1: …andQ3: …
For Agriculture the first line is Mean: 50.66. Try other columns in the Input tab: Examination, Education, Catholic.
Then run summary(swiss) on its own to see every column at once. (The psych::describe function from the reading isn't available here; summary covers most of it.)
Practise the base-R summary functions from Practice: Statistical Summary on the built-in swiss dataset.
The program reads the name of a column of swiss (for example Agriculture). Select that column with swiss[[column]], then print, each rounded to 2 decimal places:
- the mean, as
Mean: … - the standard deviation, as
SD: … - the median, as
Median: … - the first and third quartiles from
quantile(v, c(0.25, 0.75)), asQ1: …andQ3: …
For Agriculture the first line is Mean: 50.66. Try other columns in the Input tab: Examination, Education, Catholic.
Then run summary(swiss) on its own to see every column at once. (The psych::describe function from the reading isn't available here; summary covers most of it.)