0

I'm using RStudio and have an utterance variable and a syllables variable with the syllable count. Every utterance that contains "t-shirt" needs one syllable count more. (Automatically qdap syllable_sum gave "t-shirt" it 1 (it needs 2)).

An example: yellow t-shirt has 3 (it needs 4 syllables).

I don't want to write everything that I have tried that hasn't worked. I have found examples of this, but not for R that I can use.

Scarabee
  • 5,437
  • 5
  • 29
  • 55
sparkyjump
  • 97
  • 1
  • 9

1 Answers1

0

You need the magic of grepl{}

install.packages("grepl")
library(grepl)

mydf$syllables <- syllable_sum(mydf$label)
mydf$syllables <- ifelse(grepl("t-shirt", mydf$label), 
                               mydf$syllables+1, mydf$syllables)
mydf
Matt Sandgren
  • 476
  • 1
  • 4
  • 10
sparkyjump
  • 97
  • 1
  • 9
  • Where is the function `syllable_sum` coming from? Are you trying to define it on the next line? – CephBirk Jul 05 '16 at 21:05
  • The function syllable_sum is from qdap. I should have included library(qdap) in my post. Sorry that wasn't clear enough. – sparkyjump Aug 19 '16 at 02:47