RStudio, descriptive statistics, heritability, height, Galton dataset, data visualization, histograms, boxplots, scatterplot
This document provides solutions to exercises on descriptive statistics using RStudio, focusing on the heritability of height based on Galton's dataset.
[...] 200.7 44.67919 6.684249 Represent the size of girls and boys separately using histograms, boxplots. # Histograms Solution: Solution: hist(galton$height[galton$sex xlab = "Height in ylab = "Frequency"," main = "Distribution of heights among girls"," xlim = range(galton$height) + col="red")" hist(galton$height[galton$sex xlab = "Height in cm" ylab = "Frequency"" main = "Distribution of heights among boys"" xlim = range(galton$height) + col="blue")" Result in R : Result in R : # Boxplots Solution: Result in R : boxplot(galton$height ~ galton$sex, xlab = ylab = "Height in cm" main = "Distribution of heights by sex"" names = c("Girls", "Boys") col = Produce a scatterplot ("cloud of points") to see the height of children in relation to the average height of parents. [...]
[...] - The second ( [...]
[...] Introduction to descriptive statistics - Heritability statistics on RStudio Assignment 1 Exercise 1 The file galton.txt contains a classic dataset on the heritability of height in man. It was collected by Francis Galton, who was a cousin of Darwin. Import the data. Solution: Using the menu File ? Import Dataset ? From text (base)? generates this code: galton read.delim("C:/Users/Desktop/galton.txt") # Path to the file on the PC View(galton) # Visualization of the imported file Provide descriptive statistics for the size of children for all children, for girls and boys separately. [...]
[...] Solution: length(galton$sex[galton$sex & galton$height > galton$father]) Result in Interpretation of results : 231 In the dataset boys are taller than their father. Exercise 2 The file parents.txt contains the data of the parents extracted from the file galton.txt. Import the file. Solution: In using the menu File ? Import Dataset ? From text (base)? generates this code: parents read.delim("C:/Users/Desktop/parents.txt") # Path to the file on the PC View(parents) # Visualisation of the imported file Create a graph that shows the mother's size in relation to the father's size. [...]
[...] Median Mean 3rd Qu. Max. 200.7 82.82116 9.100613 # Descriptive statistics of the size of girls Solution: Result in summary(galton$height[galton$sex # stats var(galton$height[galton$sex # variance sd(galton$height[galton$sex # standard deviation Min. 1st Qu. Median Mean 3rd Qu. Max. 179.1 36.24777 6.020612 # Descriptive statistics of the height of boys Solution: Result in summary(galton$height[galton$sex # stats var(galton$height[galton$sex # variance sd(galton$height[galton$sex # standard deviation Min. 1st Qu. Median Mean 3rd Qu. [...]
APA Style reference
For your bibliographyOnline reading
with our online readerContent validated
by our reading committee