我有一个单词表,如下所示:
wordlist <- data.frame(words = c("anywhere", "youll", "feel", "comfortable", "please", "dont"))
我有另一个带有辅音列表的框架:
consonants <- data.frame(consonants = c("b", "c", "d", "f", "g", "h"))
我想在wordlist
中创建一个名为word_structure
的新变量,其中所有辅音都替换为"C"
,所有元音都替换为"V"
:
wordlist$word_structure <- c("VCCCCVCV", "CVVCC", "CVVC", "CVCCVCCVCCV", "CCVVCV", "CVCC")
我想不出如何将条件格式与gsub
相结合来获得我需要的内容.