Question 1
1A
# use read.delim() to read txt files to df's
gb.df <- read.delim('goldrickBlumstein.txt')
bach.df <- read.delim('bach.txt')
1B
# use $ and mean() to access fields in df
(mean.voiced <- mean(gb.df$VOT[gb.df$OnsetVoicing=='voiced']))
## [1] 22.66587
(mean.voiceless <- mean(gb.df$VOT[gb.df$OnsetVoicing=='voiceless']))
## [1] 65.2869
Voiced consonants have much shorter VOT than voiceless consonants.
1C
# use $ and <- to specify and add a new field
gb.df$NVOT <- gb.df$VOT/gb.df$VowelLength
1D
# use $ and mean() to access fields in df
(mean.aboveC <- mean(bach.df$Duration[bach.df$Note >= 60]))
## [1] 1.007399
(mean.belowC <- mean(bach.df$Duration[bach.df$Note < 60]))
## [1] 0.9338945
The means are much closer, although the duration is slightly longer at or above middle C.
Question 2
2A
# use hist() and subset data
hist(gb.df$VOT[gb.df$OnsetVoicing=='voiceless'])
2B
# use hist() and subset data
hist(gb.df$VowelLength[gb.df$OnsetVoicing=='voiced'])
2C
# use hist() and subset data
hist(gb.df$NVOT[gb.df$OnsetVoicing=='voiceless'])