You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure whether this is a bug / feature with Shiny or ddply, but my suspicion is the latter...
When I use ddply within a shiny app, I get an odd error where ddply cannot find a function that clearly exists. My guess is that it's something to do with the something that happens within the search path somewhere inside ddply, but I can't work it out. Here is a minimal example
library(shiny)
library(plyr)
ui <- bootstrapPage(
numericInput('n', 'minus', 0),
plotOutput('plot')
)
server <- function(input, output) {
output$plot <- renderPlot({
nn <- input$n
meanMinus <- function(x, n) {
mean(x) - n
}
print(exists('meanMinus')) ## TRUE
i2 <- ddply(
iris,
.(Species),
.fun=summarise,
blah=meanMinus(Sepal.Length, nn)
) ## Error in eval: could not find function "meanMinus"
plot(i2)
})
}
shinyApp(ui = ui, server = server)
Just to be clear, the ddply call works perfectly outside a shiny app.
It seems to me that when calling ddply within an app it's not able to examine the environment in which it is called. Yet other functions (e.g. exists) are quite comfortable with seeing the object called meanMinus.
Can anyone offer a fix if it is a bug, or a workaround / explanation if it's a feature?
The text was updated successfully, but these errors were encountered:
I'm not sure whether this is a bug / feature with Shiny or ddply, but my suspicion is the latter...
When I use
ddply
within a shiny app, I get an odd error whereddply
cannot find a function that clearly exists. My guess is that it's something to do with the something that happens within the search path somewhere insideddply
, but I can't work it out. Here is a minimal exampleJust to be clear, the ddply call works perfectly outside a shiny app.
It seems to me that when calling ddply within an app it's not able to examine the environment in which it is called. Yet other functions (e.g. exists) are quite comfortable with seeing the object called
meanMinus
.Can anyone offer a fix if it is a bug, or a workaround / explanation if it's a feature?
The text was updated successfully, but these errors were encountered: