我正在使用flexdashboard在Rmarkdown文件中制作一个闪亮的应用程序,而且我很难用一个反应函数的数据制作一个‘m图。
以下是步骤/要素:
当我使用renderPlot()来使用一个非反应性数据集(我加载了一个数据集)来生成一个is图时,我得到了正确的结果,所以ggplot部分是很好的。
这与反应性en renderPlot组合有关,但我似乎无法弄清楚。虽然这是一个“容易”的概念,但我一直有问题,抓住工作流程,尽管看了几部电影和阅读了几个指南。
这是我目前的代码:
---
title: "Tests plot"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
图书馆(柔性仪表板)
图书馆(闪亮)
图书馆(Ggplot2)
Input {.sidebar}
======================================
```{r}
radioButtons(“计数”,h3(“基准”),c("01-12-2017"="T1","06-12-2017"="T2","24-12-2017"="T3"))
Data
======================================
Column
-----------------------------------------------------------------------
### Date
```{r}
反应性({ #OK )
输入$countdate
})
Column
-----------------------------------------------------------------------
### Data
```{r}
fake2 <-反应性({read.csv2(输入$可数点,".csv",sep =“”)})
fake2 #OK
Column
-----------------------------------------------------------------------
### Plot
```{r}
ggplot1 <-反应性({
renderPlot({fake2,aes(Rij,植物))+
xlim(0,40) +
ylim(0,50) +
coord_equal() +
geom_raster(aes(fill=Wtot)) +
scale_fill_gradient(low="yellow", high="red")
})
})
ggplot1
我在情节中也试过这个:
renderPlot({
ggplot(fake2, aes(Rij, Plant)) +
xlim(0,40) +
ylim(0,50) +
coord_equal() +
geom_raster(aes(fill=Wtot)) +
scale_fill_gradient(low="yellow", high="red")
})
我的数据如下所示:
Vplaat;Rij;Plant;Mtot;Wtot
A;4;10;2;20
B;4;46;5;35
C;9;5;1;14
D;9;30;0;42
E;11;17;8;85
...
发布于 2018-01-15 02:38:02
我得到了答案,感谢一个名为Florian的开发人员,但不幸的是,他删除了他的评论。
他告诉我,在处理反应性内容时,我需要使用x()而不是x,在我的例子中:ggplot(fake2()...
而不是ggplot(fake2...
这一开始不起作用,但让我走上了正确的轨道!
除此之外,我还必须删除围绕reactive({})
函数的renderPlot,然后它才能正常工作。
所以谢谢你的帮助佛里安!
新代码:
renderPlot({
ggplot(fake2(), aes(Rij, Plant)) +
xlim(0,40) + #rijen
ylim(0,50) + #planten
coord_equal() +
geom_raster(aes(fill=Wtot)) +
scale_fill_gradient(low="yellow", high="red")
})
https://stackoverflow.com/questions/48260804
复制