I\'ve got a column people$food that has entries like chocolate or apple-orange-strawberry.
people$food
chocolate
apple-orange-strawberry
I want to split people$food>
people$food>
I would suggest using head rather than [ in R.
head
[
word <- c('apple-orange-strawberry','chocolate') sapply(strsplit(word, "-"), head, 1) # [1] "apple" "chocolate"