我在R包中有一个ShinyApp。其中一个图是{ggplot2}和函数ggplotly
。当我在一个新的Rstudio会话中运行应用程序时,这个数字是有效的。但是,如果我使用“安装并重新启动”来构建我的软件包,则会显示以下错误消息而不是图:
VECTOR_ELT()只能应用于'列表,而不是' NULL'
我可以用一个全新的R包和一个甚至不在包中的ShinyApp来重现这个问题。为此,请在Rstudio中执行以下步骤:
这是使用{ggplot2}和[plotly}
修改的基本示例#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
library(ggplot2)
library(plotly)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
plotlyOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlotly({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
# bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
g <- ggplot(data.frame(x)) +
aes(x) +
geom_histogram(bins = input$bins)
ggplotly(g)
# hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)
VECTOR_ELT()只能应用于&#39;列表,而不是&#39; NULL&#39;
(编辑)然后,如果我直接在控制台中运行它(虽然它可以正常工作)
ggiris <- qplot(Petal.Width, Sepal.Length, data = iris, color = Species)
ggplotly(ggiris)
grid.Call中的错误(C_convert,x,as.integer(whatfrom),as.integer(whatto),: VECTOR_ELT()只能应用于&#39;列表,而不是&#39; NULL&#39;
修改:如果使用devtools::install()
代替&#39;安装并重启&#39;问题没有出现
我不知道这是来自{plotly},{ggplot2}还是{devtools}。
我有: