##### to make figures 10.3 and 10.5, and perform a t-test # first, read in the file grVOT = read.delim("grVOT.txt", sep="\t", header=T) # create a subset using only the voiceless alveolar stops /t/ tVOT = subset(grVOT, place=="alv" & voicing=="vl") # break this down into two additional subsets, using the VOTs from after a time in Greece, and those that were collected after a time in the US, then multiply by 1000 to make milliseconds ustVOT = subset(tVOT,location=="US")$vot*1000 greektVOT =subset(tVOT,location=="GR")$vot*1000 # here, we set up some optional parameters for the graph. breaks tell R how to create bins, xlim and ylim tell R the range of values for the x and y axes brks = 10 xlim = c(0,35) ylim = c(0,30) # par() tells R optioanl formatting of the graph, such as font family, in this case par(family="serif") # the histogram command t hist() takes one obligatory argument, that is the vector of data you want put into the histogram, those arguments following are optional. So, you could just ask R for : hist(ustVOT) # and hist(greektVOT) # this would give you two separate histograms, done in whatever way R calculates is best for each set of data. But if you want to overlay them, you need to be more precise, which is why we set up the optional parameters above. See if you can figure out what each means. hist(ustVOT, xlim = xlim, ylim= ylim, xlab="VOT of Greek /t/ in ms" ,main="", col= "grey90" ) hist(greektVOT, xlim = xlim, ylim= ylim, xlab="", density= 20, add =T) # new # abline(v=0, col= "grey20", lty= 2) box() legend("topright", c("Greece", "US"), fill=c("black", "grey"),density= c(30, 200)) ################################################################ # to get the values for the t-test, we simply used these commands: mean(ustVOT) mean(greektVOT) sd(ustVOT)^2 sd(greektVOT)^2 length(ustVOT) length(greektVOT) # to do the t-test in R is quite straightforward t.test(greektVOT,ustVOT)