tweet<- c("boy","girl","boy","x")
unique_words<- c("asdfdd","boy","girl","ahmed","asdf","asfeertrt")
word_count<-table(tweet[tweet %in%unique_words])
word_occurence<- as.integer(unique_words%in% tweet)
Run Code Online (Sandbox Code Playgroud)
我得到了这些输出:word_count ::
boy girl
2 1
Run Code Online (Sandbox Code Playgroud)
word_occurence ::
0 1 1 0 0 0
Run Code Online (Sandbox Code Playgroud)
但我希望输出如下:0 2 1 0 0 0