Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.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
在R中的表格中插入ggplot BARPROOT_R_Ggplot2_Shiny_Reactable - Fatal编程技术网

在R中的表格中插入ggplot BARPROOT

在R中的表格中插入ggplot BARPROOT,r,ggplot2,shiny,reactable,R,Ggplot2,Shiny,Reactable,我希望重新创建一个这样的表,在其中我将ggplot图插入到单元格中。我想使用reactable生成我的表。 对如何进行有什么建议吗? 我想也许我可以使用ggsave()以png格式保存绘图。我不知道怎么插上一张表 任何协助都将不胜感激。谢谢。所以我想我没见过有人把ggplots放进reactable的单元格中。下面的屏幕截图取自。您可能需要定义一个HTML小部件,或者使用sparkline包提供的小部件 不幸的是,我对html小部件的了解还不够多,因此我认为我没有见过有人将ggplots放入

我希望重新创建一个这样的表,在其中我将ggplot图插入到单元格中。我想使用reactable生成我的表。

对如何进行有什么建议吗? 我想也许我可以使用ggsave()以png格式保存绘图。我不知道怎么插上一张表


任何协助都将不胜感激。谢谢。

所以我想我没见过有人把
ggplots
放进
reactable
的单元格中。下面的屏幕截图取自。您可能需要定义一个HTML小部件,或者使用
sparkline
包提供的小部件


不幸的是,我对html小部件的了解还不够多,因此我认为我没有见过有人将
ggplots
放入单元格中,用于
可反应的
。下面的屏幕截图取自。您可能需要定义一个HTML小部件,或者使用
sparkline
包提供的小部件


不幸的是,我对html小部件的了解还不够多,无法提供更多帮助。

我自己也有同样的问题,我发现的方法是创建一个
htmlwidget
,其中包含
ggplot
。请记住,您可以在一个可反应的单元格中包含任何HTML小部件,这就是使用sparklines时实际发生的情况。因此,您可以尝试以下方法:

library(reactable)
library(ggplot2)
library(plotly)
library(dplyr)

data <- iris
#create a fake data with placeholders
data2 <-  data %>% group_by(Species) %>% summarise(Sepal.Length = unique(Species),
                                                   Sepal.Width = unique(Species),
                                                   Petal.Length = unique(Species),
                                                   Petal.Width = unique(Species))

reactable(data2, columns = list(
  Sepal.Length = colDef(cell = function(value){
    subDB <- data[data$Species==value,]
    p<-ggplotly(
      ggplot(subDB, aes(x=Sepal.Length))+geom_density() + xlab("")
    )
    return(p)
  }),
  Sepal.Width = colDef(cell = function(value){
    subDB <- data[data$Species==value,]
    p<-ggplotly(
      ggplot(subDB, aes(x=Sepal.Width))+geom_density() + xlab("")
    )
    return(p)
  }), 
  Petal.Length = colDef(cell = function(value){
    subDB <- data[data$Species==value,]
    p<-ggplotly(
      ggplot(subDB, aes(x=Petal.Length))+geom_density()+ xlab("")
    )
    return(p)
  }),
  Petal.Width = colDef(cell = function(value){
    subDB <- data[data$Species==value,]
    p<-ggplotly(
      ggplot(subDB, aes(x=Petal.Width))+geom_density()+ xlab("")
    )
    return(p)
  })
))
库(可反应)
图书馆(GG2)
图书馆(绘本)
图书馆(dplyr)
数据%汇总(萼片长度=唯一(物种),
萼片宽度=唯一(种),
花瓣长度=独特(物种),
花瓣宽度=唯一(物种))
可反应(数据2,列=列表(
萼片长度=F(细胞=功能(值){

subDB我自己也有同样的问题,我发现的方法是创建一个
htmlwidget
,里面有
ggplot
。记住,你可以在一个可反应的单元格中包含任何HTML小部件,这就是使用sparklines时实际发生的情况。因此,你可以尝试以下方法:

library(reactable)
library(ggplot2)
library(plotly)
library(dplyr)

data <- iris
#create a fake data with placeholders
data2 <-  data %>% group_by(Species) %>% summarise(Sepal.Length = unique(Species),
                                                   Sepal.Width = unique(Species),
                                                   Petal.Length = unique(Species),
                                                   Petal.Width = unique(Species))

reactable(data2, columns = list(
  Sepal.Length = colDef(cell = function(value){
    subDB <- data[data$Species==value,]
    p<-ggplotly(
      ggplot(subDB, aes(x=Sepal.Length))+geom_density() + xlab("")
    )
    return(p)
  }),
  Sepal.Width = colDef(cell = function(value){
    subDB <- data[data$Species==value,]
    p<-ggplotly(
      ggplot(subDB, aes(x=Sepal.Width))+geom_density() + xlab("")
    )
    return(p)
  }), 
  Petal.Length = colDef(cell = function(value){
    subDB <- data[data$Species==value,]
    p<-ggplotly(
      ggplot(subDB, aes(x=Petal.Length))+geom_density()+ xlab("")
    )
    return(p)
  }),
  Petal.Width = colDef(cell = function(value){
    subDB <- data[data$Species==value,]
    p<-ggplotly(
      ggplot(subDB, aes(x=Petal.Width))+geom_density()+ xlab("")
    )
    return(p)
  })
))
库(可反应)
图书馆(GG2)
图书馆(绘本)
图书馆(dplyr)
数据%汇总(萼片长度=唯一(物种),
萼片宽度=唯一(种),
花瓣长度=独特(物种),
花瓣宽度=唯一(物种))
可反应(数据2,列=列表(
萼片长度=F(细胞=功能(值){

subDB感谢您的帮助。不幸的是,它不处理单杠(或我不知道如何处理)感谢您的帮助。不幸的是,它不处理单杠(或我不知道如何处理)