単語で構成されたリストがあります。
> head(splitWords2)
[[1]]
[1] "Some" "additional" "information" "that" "we" "would" "need" "to" "replicate" "the"
[11] "experiment" "is" "how" "much" "vinegar" "should" "be" "placed" "in" "each"
[21] "identical" "container" "or" "what" "tool" "use" "measure" "mass" "of" "four"
[31] "different" "samples" "and" "distilled" "water" "rinse" "after" "taking" "them" "out"
[[2]]
[1] "After" "reading" "the" "expirement" "I" "realized" "that" "additional" "information" "you"
[11] "need" "to" "replicate" "expireiment" "is" "one" "amant" "of" "vinegar" "poured"
[21] "in" "each" "container" "two" "label" "containers" "before" "start" "yar" "and"
[31] "three" "write" "a" "conclusion" "make" "sure" "results" "are" "accurate"
リスト全体の合計出現回数ではなく、リストの各要素の出現回数をカウントしたい単語のベクトルがあります。
パッケージの機能と機能の1つをstr_count()
組み合わせる方法だと思いますが、機能させることができません。stringr
*ply()
numWorder1 <- sapply(ifelse(str_count(unlist(splitWords2), ignore.case("we" ) )> 0, 1, 0))
ここで、"we" は最終的に の出現回数をカウントする単語のベクトルからの単語になります。
私の理想的な出力は次のようになります。
lineNum count
1 0
2 1
3 1
4 0
... ...
助言がありますか?