从R数据表中提取json文件

从R数据表中提取json文件,json,r,datatable,dt,Json,R,Datatable,Dt,我有一个像这样的R data.frame: df <- data.frame(RowNames <- c("FirstCol","SecondCol","ThirdCol","FourthCol"), FirstCol <- c(0.1,0,0,0.28), SecondCol <- c(0,0,0.1,0), ThirdCol <- c(0,0,0,0.3),

我有一个像这样的R data.frame:

df <- data.frame(RowNames <- c("FirstCol","SecondCol","ThirdCol","FourthCol"),
             FirstCol <- c(0.1,0,0,0.28),
             SecondCol <- c(0,0,0.1,0),
             ThirdCol <- c(0,0,0,0.3),
             FourthCol <- c(0.28,0,0,0.7),
             FifthCol <- c("hi","hello","cus","good bye"))
names(df) <- c("RowNames", "FirstCol", "SecondCol", "ThirdCol", "FourthCol","FifthCol")

df看看这个。jsonlite::toJSON(df)或只需
htmlwidgets::saveWidget()
,即可获得可嵌入的全部内容
library(DT)
dt <- datatable(df)