Table of Contents |
---|
...
Code Block | ||
---|---|---|
| ||
subset.4<-subset(dataframe, x < 5) #subset of the whole dataframe where x < 5 subset.4<-subset(dataframe, x == 5) #subset of the whole dataframe where x = 5 |
- create a subset of
sim.alspac
for males calledsubset.male
and for females calledsubset.female
- How many participants are female and how many are male? HINT: Use
dim
to check the dimensions ofsubset.male
andsubset.female
.
Changing class
- The data dictionary tells us that the variable
male
is categorical. Check the class ofmale
using theclass
function.
Exploring the data
- Get object summary statistics by using the
summary
function onsubset.male
andsubset.female
- Use the
boxplot
function to plot BMI at age 7 against gender. HINT: You will only need to use the argumentsformula=
anddata=
- Use the
hist
function to plot histograms of BMI age 7 for females and males. HINT: You can layer graphs over one another by using the argumentadd=T
in the second histogram. Line colour of the histogram can be set using the argument e.g.border="red"
- Make the plot more readable by using the
legend
to add an appropriate key. - Output your graph as a .png file using the
png
function.
Modelling
Rounding numbers
signif(x, digits = 6)
...