【发布时间】:2019-12-03 02:11:52
【问题描述】:
我有两个数据集。一个是包含 72 个项目的列表,其中每个项目本身就是一个包含 10 个句子的列表。因此,我总共有 720 个句子,每个句子由 10 个列表分隔。
第二组数据是第一个数据集中所有以“ing”结尾的单词的列表。
我想查看每个列表项,如果在所述列表的十个句子中的任何一个中包含“ing”字。
如果是这样,列表中存在哪些单词?这是该单词第一次出现在整个数据集中(即第一次出现在所有 720 个句子中)?然后我计划将所有这些信息编译成一个表格
这是我目前所拥有的。我只是想看看它是否会打印出每个 ing 单词所在的列表,然后再转到更复杂的部分。
n <- 1
harvardList[1]
for(word in IngWords){
if(IngWords==harvardList[n])
print(harvardList[n])
n <- n+1
}
当我运行该脚本时,我得到这些错误和输出:
Error: unexpected 'in' in:
"for(word in IngWords){
if(word in"
print(harvardList[n])
$`List 1`
$`List 1`[[1]]
[1] "The birch canoe slid on the smooth planks."
etc.,
> n <- n+1
> }
Error: unexpected '}' in "}"
这是一个迷你版的句子列表:
$`List 1`[[1]]
[1] "The source of the huge river is the clear spring."
$`List 1`[[2]]
[1] "Help the woman get back to her feet."
$`List 1`[[3]]
[1] "A pot of tea helps to pass the evening."
$`List 2`[[1]]
[1] "The colt reared and threw the tall rider."
$`List 2`[[2]]
[1] "It snowed, rained, and hailed the same morning."
$`List 2`[[3]]
[1] "Read verse out loud for pleasure."
$`List 3`[[1]]
[1] "Take the winding path to reach the lake."
$`List 3`[[2]]
[1] "The meal was cooked before the bell rang."
$`List 3`[[3]]
[1] "What joy there is in living."
这些是 ing 词:
生活蜿蜒的早晨晚上春天
预期输出:
[List Number] [ing-word]
1 spring, evening
2 morning
3 winding, living
【问题讨论】: