If you want it, you can do it in one layer:
R> text <- c("ABC Industries", "ABC Enterprises", + "123 and 456 Corporation", "XYZ Company") R> table(do.call(c, lapply(text, function(x) unlist(strsplit(x, " "))))) 123 456 ABC and Company 1 1 2 1 1 Corporation Enterprises Industries XYZ 1 1 1 1 R>
Here I use strsplit() to break down each login element; this returns a list (in a list). I use do.call() to simply combine all the resulting lists into a single vector, which is summarized by table() .
source share