【发布时间】:2021-07-18 06:09:16
【问题描述】:
我正在尝试将多个 json 文件读取到工作目录中,以进一步转换为数据集。我在目录 json 中有文件 text1、text2、text3。这是我写的代码:
setwd("Users/Desktop/json")
temp = list.files(pattern="text*.")
myfiles = lapply(temp, read.delim)
library("rjson")
json_file <- "myfiles"
library(jsonlite)
out <- jsonlite::fromJSON(json_file)
out[vapply(out, is.null, logical(1))] <- "none"
data.frame(out, stringsAsFactors = FALSE)[,1:5]
View(out)
我有大约 200 个文件,所以我想知道是否可以导入 json 文件。
谢谢
【问题讨论】:
-
看看this解决方案。