# Load in the data
data("ToothGrowth")
# Learn about the data
#?ToothGrowth
# Structure of the dataset
str(ToothGrowth)
## 'data.frame': 60 obs. of 3 variables:
## $ len : num 4.2 11.5 7.3 5.8 6.4 10 11.2 11.2 5.2 7 ...
## $ supp: Factor w/ 2 levels "OJ","VC": 2 2 2 2 2 2 2 2 2 2 ...
## $ dose: num 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 ...
# Look at the data
#View(ToothGrowth)
library(tidyverse)
library(ggplot2)
The rows of this dataset represent 1 of the 60 guinea pig test subjects.
Len represents the length of odontoblasts. Supp represents which supplement the guinea pig was given, either orange juice(OJ) or ascorbic acid(VC). Dose represents how many mg of vitamin C the guinea pig was given. Supplement is a categorical variable, it is not ordinal. Length and dose are numerical variables. Length is continuous and dose is discrete.
The response variable is the length of odontoblasts in the guinea pigs. The explanatory variables are the type of supplement and the dose of the supplement.
If a guinea pig is given vitamin C from orange juice it will have bigger teeth than a guinea pig who got less vitamin C from orange juice, or a guinea pig that gets its vitamin C from ascorbic acid.
I’ve created a boxplot to compare type of supplement to length of odontoblasts
ggplot(ToothGrowth,aes(x=supp, y=len, color=supp))+geom_boxplot()
Added facets to compare specific doses of the supplements in a clearer manner.
ggplot(ToothGrowth,aes(x=supp, y=len, color=supp))+geom_boxplot()+
facet_wrap(~dose)
The data shows that a dose of .5 mg orange juice benefits guinea pigs more than a .5 mg dose of ascorbic acid. OJ has a fairly large variance from ~8 to ~22 length of odontoblasts, while ascorbic acid varies less, from ~4 to ~12. In a 1 mg dose orange juice takes the lead in tooth growth by far, with a median of ~24. A 1 mg dose of ascorbic acid has a median of ~17, there is one outlier at ~23. My hypothesis really starts to be tested when it comes to a 2 mg dose. Orange juice and ascorbic acid have almost the same median of ~27. However ascorbic acid has a much greater spread, lower doses of ascorbic acid had a much smaller spread. For the most consistent and successful results orange juice takes the lead in teeth growth.
My hypothesis is supported by the data. A higher supplement dose always improves teeth growth and orange juice gives more consistent, better results than ascorbic acid. I found it surprising that a 2 mg dose of ascorbic acid actually had the same median of toothgrowth as a 2 mg dose of orange juice. I now wonder if a 2.5 mg dose of ascorbic acid would surpass a 2.5 mg dose of orange juice.