R shiny table 在 table 内有图
R shiny table with plots inside the table
我正在开发一个 R shiny 应用程序,理想情况下,我需要精确地执行此处所做的操作:
更具体地说,我有包含股票开盘价、收盘价、高价、低价数据的数据框,我需要复制附件图像中“范围”列中显示的内容。
我知道我应该附上一些代码,但事实是,我找不到与我在网上询问的内容相近的内容。
示例数据框为:
df = data.frame(STOCK=c("IBM","MSFT","FB"), OPEN=c(100,90, 80), CLOSE=c(102, 85, 82), LOW=c(99,81,78), HIGH=c(105, 91, 88))
然后,我不知道从这里开始做什么。有什么建议么?谢谢
您可以按照本指南使用自定义渲染
https://glin.github.io/reactable/articles/examples.html#custom-rendering-1
library(dplyr)
library(sparkline)
data <- chickwts %>%
group_by(feed) %>%
summarise(weight = list(weight)) %>%
mutate(boxplot = NA, sparkline = NA)
reactable(data, columns = list(
weight = colDef(cell = function(values) {
sparkline(values, type = "bar", chartRangeMin = 0, chartRangeMax = max(chickwts$weight))
}),
boxplot = colDef(cell = function(value, index) {
sparkline(data$weight[[index]], type = "box")
}),
sparkline = colDef(cell = function(value, index) {
sparkline(data$weight[[index]])
})
))
我正在开发一个 R shiny 应用程序,理想情况下,我需要精确地执行此处所做的操作:
更具体地说,我有包含股票开盘价、收盘价、高价、低价数据的数据框,我需要复制附件图像中“范围”列中显示的内容。 我知道我应该附上一些代码,但事实是,我找不到与我在网上询问的内容相近的内容。 示例数据框为:
df = data.frame(STOCK=c("IBM","MSFT","FB"), OPEN=c(100,90, 80), CLOSE=c(102, 85, 82), LOW=c(99,81,78), HIGH=c(105, 91, 88))
然后,我不知道从这里开始做什么。有什么建议么?谢谢
您可以按照本指南使用自定义渲染
https://glin.github.io/reactable/articles/examples.html#custom-rendering-1
library(dplyr)
library(sparkline)
data <- chickwts %>%
group_by(feed) %>%
summarise(weight = list(weight)) %>%
mutate(boxplot = NA, sparkline = NA)
reactable(data, columns = list(
weight = colDef(cell = function(values) {
sparkline(values, type = "bar", chartRangeMin = 0, chartRangeMax = max(chickwts$weight))
}),
boxplot = colDef(cell = function(value, index) {
sparkline(data$weight[[index]], type = "box")
}),
sparkline = colDef(cell = function(value, index) {
sparkline(data$weight[[index]])
})
))