【发布时间】:2022-09-27 19:26:00
【问题描述】:
我目前在某些代码中将可反应存储为对象。我希望能够将所述对象转换为 ggplot,但无论我做什么,我都会得到相同错误的变体。 使用 blastula 的 add_ggplot 函数,我得到:
Error in UseMethod(\"grid.draw\") :
no applicable method for \'grid.draw\' applied to an object of class \"c(\'reactable\', \'htmlwidget\')\"
使用 ggplotify 的 as.ggplot 函数,我得到:
Error in UseMethod(\"as.grob\") :
no applicable method for \'as.grob\' applied to an object of class \"c(\'reactable\', \'htmlwidget\')\"
有没有人有关于如何达到预期结果的建议?
编辑:在回答一个问题时,我可能本来应该回答:reactable 源自一个非常普通的数据框。
df <- structure(list(Date = c(\"2019-02-09\", \"2019-02-09\", \"2019-02-09\",
\"2019-02-09\", \"2019-02-09\", \"2019-02-09\", \"2020-02-09\", \"2020-02-09\",
\"2020-02-09\", \"2020-02-09\", \"2021-02-09\", \"2021-02-09\", \"2021-02-09\",
\"2021-02-09\"), Type = c(\"HUF\", \"HAD\", \"WOK\", \"STR\", \"HUF\", \"HAD\",
\"WOK\", \"STR\", \"HUF\", \"HAD\", \"WOK\", \"STR\", \"HUF\", \"HAD\"), Value = c(12L,
226394L, 27566L, 217098L, 208463L, 9320L, 156607L, 19790L, 24541L,
1074419L, 17250L, 12249L, 43651L, 45121L)), class = \"data.frame\", row.names = c(NA,
-14L))
EDIT2:这是可反应的代码,很抱歉之前没有包括它:
react_df <- reactable(df, highlight = TRUE, compact = TRUE,pagination = FALSE, columns = list(Date = colDef(name = \"Last Recorded\", align = \'center\'), Type = colDef(name = \"Category\", align = \'center\'), Value = colDef(name = \"Change(s)\", align = \'center\', cell = data_bars(df, background = \"white\", border_width = \"2px\", bar_height = 3, align_bars = \"left\", text_position = \"outside-end\", max_value = 1, number_fmt = scales::percent))))
react_df
-
“可反应”是如何制成的?您提到的功能是将
ggplot转换为HTML;它不会创建ggplot。用这么少的信息来帮助解决这个问题是很困难的。 -
我很愚蠢地留下了一些信息,但我已经更新了它。感谢您对问题的初步考虑。
-
你能分享一些代码来创建你的反应吗?
-
啊抱歉,现在添加