R中的readHTMLTable在for循环内引发警告

布鲁塞普林

嗨,我有5个html源,我想readHTMLTable在每个源上运行并存储结果。我可以使用以下方法单独执行此操作:

readHTMLTable(iso.content[1],which=6)
readHTMLTable(iso.content[2],which=6)
.
.

但是,当将其放入for循环中时,我得到:

library(XML)
> iso.table<-NULL
> for (i in 1:nrow(gene.iso)) { 
+ iso.table[i]<-readHTMLTable(iso.content[i],which=6)
+ }
Warning messages:
1: In iso.table[i] <- readHTMLTable(iso.content[i], which = 6) :
  number of items to replace is not a multiple of replacement length
2: In iso.table[i] <- readHTMLTable(iso.content[i], which = 6) :
  number of items to replace is not a multiple of replacement length
3: In iso.table[i] <- readHTMLTable(iso.content[i], which = 6) :
  number of items to replace is not a multiple of replacement length
4: In iso.table[i] <- readHTMLTable(iso.content[i], which = 6) :
  number of items to replace is not a multiple of replacement length
5: In iso.table[i] <- readHTMLTable(iso.content[i], which = 6) :
  number of items to replace is not a multiple of replacement length

因此,我可以单独执行此操作,但不能使用for循环。我的目标不是要用下一次迭代替换当前数据,所以我不确定为什么警告会出现这种情况。

有任何想法吗?

弗里克先生

该错误与readHTMLTable实际无关都是关于iso.table我不确定您想要的对象类型是什么,但是如果您想存储一堆data.frames,则需要一个列表。当您将对象分配给列表时,您要使用[[ ]]not来放置它们[ ]尝试

iso.table <- list()
for (i in 1:nrow(gene.iso)) { 
    iso.table[[i]] <- readHTMLTable(iso.content[i],which=6)
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章