将plot_y表从.JSON导入到R

将plot_y表从.JSON导入到R,r,json,plotly,r-plotly,R,Json,Plotly,R Plotly,我使用plot\u ly()创建了一个表,然后将其转换为.JSON并保存在本地 现在,我想在R中打开保存的文件来检查创建的表,但是我很难打开这样的文件 这就是我导出文件的方式 tab <- plot_ly( # creates table )) tab例如,您可以使用jsonlite::fromJSON。你可以找到其他的选择 请检查以下内容: library(plotly) library(datasets) library(jsonlite) tab <- plot

我使用
plot\u ly()
创建了一个表,然后将其转换为.JSON并保存在本地

现在,我想在R中打开保存的文件来检查创建的表,但是我很难打开这样的文件

这就是我导出文件的方式

tab <- plot_ly(

# creates table

    ))

tab例如,您可以使用
jsonlite::fromJSON
。你可以找到其他的选择

请检查以下内容:

library(plotly)
library(datasets)
library(jsonlite)

tab <- plot_ly(
  type = 'table',
  columnwidth = c(100, 100),
  columnorder = c(0, 1),
  header = list(
    values = c("Cut","Price"),
    align = c("center", "center"),
    line = list(width = 1, color = 'black'),
    fill = list(color = c("grey", "grey")),
    font = list(family = "Arial", size = 14, color = "white")
  ),
  cells = list(
    values = rbind(head(diamonds)$cut, head(diamonds)$price),
    align = c("center", "center"),
    line = list(color = "black", width = 1),
    font = list(family = "Arial", size = 12, color = c("black"))
  ))

tab_json <- plotly_json(tab, FALSE)
write(tab_json, "summary.json")

tab_data <- fromJSON("summary.json", flatten = TRUE)
tab_data$data$cells.values[[1]]
library(plotly)
图书馆(数据集)
图书馆(jsonlite)

你现在有没有检查我的答案?谢谢你的提醒
library(plotly)
library(datasets)
library(jsonlite)

tab <- plot_ly(
  type = 'table',
  columnwidth = c(100, 100),
  columnorder = c(0, 1),
  header = list(
    values = c("Cut","Price"),
    align = c("center", "center"),
    line = list(width = 1, color = 'black'),
    fill = list(color = c("grey", "grey")),
    font = list(family = "Arial", size = 14, color = "white")
  ),
  cells = list(
    values = rbind(head(diamonds)$cut, head(diamonds)$price),
    align = c("center", "center"),
    line = list(color = "black", width = 1),
    font = list(family = "Arial", size = 12, color = c("black"))
  ))

tab_json <- plotly_json(tab, FALSE)
write(tab_json, "summary.json")

tab_data <- fromJSON("summary.json", flatten = TRUE)
tab_data$data$cells.values[[1]]