Table of Contents |
---|
...
Info | ||
---|---|---|
| ||
The names of all other variables end in either .7 or .11 (depending whether they were measured at the age 7 clinic or the age 11 clinic) male codes sex: 1=male, 0=female age.yrs and age.yrs are the age (in decimal years) on the day of the clinic at age 7 or 11 ht is height in cm ht.sit is sitting height in cm ws is waist circumference in cm hp is waist hip circumference in cm wt is weight in Kg sbp is systolic blood pressure (the top of the blood pressure fluctuation) measured (as is conventional) in mm of Hg (mercury) dbp is diastolic blood pressure (the bottom of the blood pressure fluctuation) measured (as is conventional) in mm of Hg (mercury) pulse is pulse rate measured in beats per minute BMI is body mass index derived as wt/(ht/100)2 The height variable is divided by 100 to express it in metres rather than centimeters |
...
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
.
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=
- Output your boxplot as a .png file using the
png
function. - 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 histogram as a .png file using the
png
function. - Use the
plot
function to create a scatter plot of height and weight age 7 for males. - Use
lm
function to generate a linear model calledlm1
for the two variables. HINT: R uses formula notation in formula argument e.g.formula=y~x
- Use the
summary
function on lm1 to get the coefficients. - You can add your regression line to the scatterplot by running the
abline
function on lm1 after yourplot
function
Modelling
- Apply a generalised linear model (glm) using the glm function to find the linear relationship between BMI age 7 and gender
ds.glm("D$LAB_GLUC_FASTING~1+D$GENDER",family="gaussian")