我有一个单词列表
for( ; c <= n; a = a*c, c = c +5)
{
}
printf("The result is %d\nDo you want do it again? (Type 'Y' for yes and 'N' for no)", a);
ch = getchar();
一个数据框,其中包含每个单词在文本中的频率:
[[1]]
[1] Hello
[2] all
[3] the
[4] world
[[2]]
[1] world
[2] my
[3] Hi
我想知道是否有任何方法可以从字符串列表中删除数据框的每个字符串。例如,如果我删除单词&#34; Hello&#34; 我会得到:
Var1 Freq
Hello 54
all 178
the 53
entire 57
world 49
PS:@Julius的另一个例子
[[1]]
[1] all
[2] the
[3] world
[[2]]
[1] world
[2] my
[3] Hi
因为&#34; b&#34;之前的所有字母用&#34; b&#34;被删除。
答案 0 :(得分:2)
(l <- list(letters[1:2], letters[2:3]))
# [[1]]
# [1] "a" "b"
#
# [[2]]
# [1] "b" "c"
(r <- letters[2])
# [1] "b"
lapply(l, setdiff, r)
# [[1]]
# [1] "a"
#
# [[2]]
# [1] "c"