使用R闪亮服务器和ggplot一起使用 [英] using R shiny server together with ggplot
本文介绍了使用R闪亮服务器和ggplot一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ggplot绘制饼图,如下面的RStudio代码及其工作正常。
Am using ggplot to plot a pie chart as in the code below in RStudio and its working fine. the problem is when i want to use R shiny server.
indicatorTotals<-tapply(anc_data$Total,anc_data$Indicator,sum)
graphdatapie <- as.data.frame(indicatorTotals)
c <- ggplot(graphdatapie, aes(x=rownames(graphdatapie),y=indicatorTotals,fill =
indicatorTotals)) + geom_bar(width = 1,stat="identity")
print(c + coord_polar(theta = "y"))
数据为此格式
the data is this format
indicatorTotals
ANC 1st visit 248777
ANC 2nd visit 231914
ANC 3rd visit 162062
ANC 4th or more visits 99528
<
I get the following error message from the R shiny server ui.R.
Error:object 'graphdatapie' not found.
可能是什么问题?
What could be the problem???
推荐答案
将以下内容添加到ggplot函数中: environment = environment() ,即
Add the following to the ggplot function: environment=environment() i.e
ggplot(graphdatapie, aes(x=rownames(graphdatapie),y=indicatorTotals,fill =
indicatorTotals), environment=environment())
然后重新启动shiny-server。这将解决问题。
Then restart the shiny-server. That will solve the problem.
这篇关于使用R闪亮服务器和ggplot一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文