我对在闪亮中使用 R 时打印动态输出有点困惑。以下是我的闪亮代码,它可以打印出 ggplot2 图表,但不能与新数据框一起打印。我只想知道如何同时打印出“mydata”。谢谢。
library("reshape2")
library("ggplot2")
服务器.R
shinyServer(function(input, output) {
output$main_plot <- renderPlot({
#Draw gragh to compare the forecast values with real data
mydata <- data.frame(years, A, B)
df <- melt(mydata, id = 'years', variable = 'series')
print(ggplot(df, aes(years,value)) + geom_line(aes(colour = series), size=1.5))
})
用户界面
shinyUI(pageWithSidebar(
# Sidebar with controls to select a dataset
# of observations to view
sidebarPanel(
selectInput("dataset", "Choose a dataset:",
choices = c("Netflix"))),
plotOutput(outputId = "main_plot", height = "500px")
))