Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在rmongodb中运行mongo.cursor.to.data.frame函数时出现警告消息_R_Rmongodb - Fatal编程技术网

在rmongodb中运行mongo.cursor.to.data.frame函数时出现警告消息

在rmongodb中运行mongo.cursor.to.data.frame函数时出现警告消息,r,rmongodb,R,Rmongodb,当我运行查询时 mongo.cursor.to.data.frame(cursor) 要使用rmongodb将集合中的文档提取到R中的数据帧,我收到警告消息: In mongo.cursor.to.data.frame(cursor) : This fails for most NoSQL data structures. I am working on a new solution 我查看了一些关于rmongodb的文章,我也发现了上面提到的这条消息。此警告是否意味着结果数据框中可能存在一

当我运行查询时

mongo.cursor.to.data.frame(cursor)
要使用
rmongodb
将集合中的文档提取到R中的数据帧,我收到警告消息:

In mongo.cursor.to.data.frame(cursor) : This fails for most NoSQL data structures. I am working on a new solution
我查看了一些关于rmongodb的文章,我也发现了上面提到的这条消息。此警告是否意味着结果数据框中可能存在一些问题?

显示了问题可能出现的位置

mongo.cursor.to.data.frame <- function(cursor, nullToNA=TRUE, ...){

  warning("This fails for most NoSQL data structures. I am working on a new solution")

  res <- data.frame()
  while ( mongo.cursor.next(cursor) ){
    val <- mongo.bson.to.list(mongo.cursor.value(cursor))

    if( nullToNA == TRUE )
      val[sapply(val, is.null)] <- NA

    # remove mongo.oid -> data.frame can not deal with that!
    val <- val[sapply(val, class) != 'mongo.oid']

    res <- rbind.fill(res, as.data.frame(val, ... ))

  }
  return( as.data.frame(res) )
}

在这一点上,我应该提到这个包,它通常更快,但再次返回一个
data.frame

还有我对mongolite的扩展(还没有在CRAN上),它更快,检索数据也更快,但同样受到限制,结果必须强制转换为
数据。表

## consider the JSON structure
## [{"a":[1,2,3],"b":["a","b","c"]},{"d":[1.1,2.2,3.3],"e":[["nested","list"]]}] 

##Which in R is the same as
lst = list(list(a = c(1L,2L,3L),
                b = c("a","b","c")),
           list(d = c(1.1, 2.2, 3.3),
                e = list(c("nested", "list"))))

## this errors when coerced to a data.frame
as.data.frame(lst)
Error in data.frame(d = c(1.1, 2.2, 3.3), e = list(c("nested", "list")),  : 
  arguments imply differing number of rows: 3, 2