0
私は光っているアプリのためにggplotからプロットしていますが、Rstudioからアプリを実行するとブラウザでプロットが表示されません。次の最小限の例は、ggplotに戻っても動作します。ありがとう!shiny plotly no graph
ui.R
library(shiny)
library(httr)
library(jsonlite)
# get the list of all packages on CRAN
package_names = names(httr::content(httr::GET("http://crandb.r-
pkg.org/-/desc")))
shinyUI(fluidPage(
# Application title
"R Package Downloads",
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
br(),
selectInput("package",
label = "Packages",
selected = "ggplot2", # initialize the graph with a random package
choices = package_names,
multiple = TRUE),
selectInput("plot1",
label = "Select Plot Type",
choices = c("","Downloads vs Time (monthly)","Downloads vs Time (cumulative)","Map (cumulative)","Map (dominance)"),
multiple = FALSE)),
# Show a plot of the generated distribution
mainPanel(
plotlyOutput("plot1")
))
))
plotlyOutputがあるのので、私は別の名前に "plot1" からselectInputの名前を変更することでこの問題を解決するために管理
library(shiny,quietly = T); library(stringr,quietly = T)
library(dplyr,quietly = T); library(plotly,quietly = T)
library(ggplot2,quietly = T); library(lubridate,quietly = T)
library(cranlogs,quietly = T); library(zoo,quietly = T)
library(scales,quietly = T); library(broom,quietly = T)
library(rworldmap,quietly = T); library(countrycode,quietly = T)
library(data.table,quietly = T)
shinyServer(function(input, output) {
load("CRANlog_cleaned_month.RData")
output$plot1 <- renderPlotly({
dat.p <<- subset(dat,package %in% input$package)
dat.ts <<- aggregate(times~package+month,data=dat.p,sum)
DTmonthly <<- ggplot(dat.ts, aes(month, times, color = package)) +
geom_line() + xlab("Date") + scale_y_continuous(name="Number of downloads", labels = comma)
gg <- ggplotly(DTmonthly)
gg
})
})
ファイル「CRANlog_cleaned_month.RData」がなくても動作しますが、何が間違っているかを実際に知る方法はありません。よく見えます。 MWEを作成すると(最小限の実例)、我々が手助けできるかもしれない。 –