首页 > 解决方案 > 将列表转换为R中的DataFrame?错误:获取默认列名(x1、x2、x3..)而不是列表中的名称

问题描述

我正在尝试将大约 200 行 json 字符串转换为 R 中的数据框。我最终在数据框中获取默认列名,而不是列表中提到的列名。这是我的代码:

 out <- lapply(readLines("exampleFile.json", n=200), fromJSON) // Used to convert json into a list
 test <- data.frame(t(sapply(out,c))) //convert the list into a dataframe

附件是变量'out'结果的截图在此处输入图像描述

附件是变量“测试”结果的截图 在此处输入图像描述

感谢任何帮助!

标签: rjsonlistdataframe

解决方案


推荐阅读