library(magrittr)
library(dplyr)
library(tidytext)
word_list <- c("silence", "autism", "reticent")
x = "People with autism spectrum disorder often have difficulty processing sensory information around them."
text_df <- tibble(text = x)
text_df %<>%
unnest_tokens(word, text)
text_df$word[text_df$word %in% word_list] <- 1
paste(text_df$word, sep = " ", collapse = " ")
问题就是把标点去掉了,还多了空格,没有了大小写。水平有限,请您见谅。