I have a table of tfvalues ββwith column headers formant vowel length IL SG.
This is how I get their values:
f1a <- subset(tf, tf$vowel=='a' & tf$formant=='F1')$IL
f2a <- subset(tf, tf$vowel=='a' & tf$formant=='F2')$IL
f1e <- subset(tf, tf$vowel=='e' & tf$formant=='F1')$IL
f2e <- subset(tf, tf$vowel=='e' & tf$formant=='F2')$IL
Is there a way to rewrite this with a loop for a given vowels <- c('a', 'e', 'i', 'o', 'u')? Or is there a different approach?
Decision: split
Using split, the above can be easily achieved with just one line:
fvowels = split(tf$IL, paste(tolower(tf$formant), tf$vowel, sep=""))
Where:
splitDrag and drop data in tf$ILaccordance with the second part of the argument;pasteCombines elements after they are converted to string;tolower changes characters to lower case.
Result in fvowelsis a data set from f1ato f3u.
source
share