我reactable
在 Rmarkdown 文档中有一个表格,单元格中有图表。默认情况下,这些单元格的高度为 500 像素。我怎样才能控制这个高度?
代码就是这个答案https://stackoverflow.com/a/66271453/10624798给出了我的意思的一个例子。理想情况下,我希望密度图只有 200px 高。
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)
})
))