如何自动计算列表中不同字符串的出现次数

How to automatically count the occurrence of different strings in a list

我有一个包含约 1000 个条目的列表,其结构如下(小示例):

example <- list(
"1" =c("car","house"), 
"2" = c("family","work","car"), 
"3" = c("house","Work","car"),
"4" = "school", 
"5" = c("Car","school"))

列表中的大多数条目仅包含 1 个字符串。有些包含 2、3、4、5 甚至更多字符串。 我不知道字符串的最大值,因为我不知道如何在不滚动所有 ~1000 行数据的情况下获取此信息。

我想获得列表中字符串的摘要。我想知道:

all_strings <- tolower(unlist(example, use.names = FALSE))
#How many different string
length(unique(all_strings))
#[1] 5

#How often the different strings occur
all_string_listwise <- tolower(unlist(lapply(example, unique)))
table(all_string_listwise)

#all_string_listwise
#   car family  house school   work 
#     4      1      2      2      2