dn = read.table(file.path(pfad, "dn.txt"), header=T) flog = log(dn$f) dn[,2] = flog # subtract a speaker's f0 values from the speaker's same # f0 values for "B" in sentence 1 dfn = rep(0, nrow(dn)) for(j in unique(dn$Vpn)){ dfn[dn$Vpn == j] = dn$f[dn$Vpn == j] - dn$f[dn$Vpn == j & dn$Buch == "B" & dn$Satz=="S1"] } dn = cbind(dfn, dn) temp = dn$Satz == "S1" dn1 = dn[temp,] # aggregate over Buch dn1m = with(dn1, aggregate(dfn, list(Buch), mean)) temp = dn$Satz == "S2" dn2 = dn[temp,] # aggregate over Buch dn2m = with(dn2, aggregate(dfn, list(Buch), mean)) temp = dn$Satz == "S3" dn3 = dn[temp,] # aggregate over Buch dn3m = with(dn3, aggregate(dfn, list(Buch), mean)) temp = dn$Satz == "S4" dn4 = dn[temp,] # aggregate over Buch dn4m = with(dn4, aggregate(dfn, list(Buch), mean)) ylim = range(c(dn1m[,2], dn2m[,2], dn3m[,2], dn4m[,2])) xlim = c(1,5) plot(1:5, dn1m[,2], ylim=ylim, pch=4, type="b", axes=F, xlab="", ylab="", xlim=xlim) par(new=T) plot(1:3, dn2m[,2], ylim=ylim, pch=15, type="b", axes=F, xlab="", ylab="", lty=2, xlim=xlim) par(new=T) plot(1:5, dn3m[,2], ylim=ylim, pch=16, type="b", axes=F, xlab="", ylab="", xlim=xlim, col="red") par(new=T) plot(1:5, dn4m[,2], ylim=ylim, pch=17, type="b", axes=F, xlab="", ylab="log Hz", xlim=xlim, col="blue") axis(side=1, at = 1:5, labels=c("B", "D", "G", "W", "B")) axis(side=2) legend(locator(1), c("S1", "S2", "S3", "S4"), col = c("black", "black", "red", "blue"), lty=c(1, 2, 1, 1)) temp = dn$Buch == "B" & dn$Satz=="S2" boxplot(dn[temp,1]) temp = dn$Buch == "W" & dn$Satz %in% c("S1", "S4") temp2 = dn$Buch == "X" & dn$Satz %in% c("S1", "S4") vals = dn[temp,2] - dn[temp2,2] labs = dn$Satz[temp] labs = factor(labs) boxplot(vals ~ labs)