Monday, February 11, 2019

R Shiny - Subset dataframe based on reactive input

I am building a shiny app and I need to subset a dataframe based on a user input. I have tried many different ways to do this but I keep running into errors. Currently, this seems to be the simplest method but I get the following error:


Warning in is.na(e2) : is.na() applied to non-(list or vector) of type 'closure'
Error in ==.default(test$MARKET, var) : comparison (1) is possible only for atomic and list types


I am pretty stuck. Does anyone have some guidance for me? Thanks!


library(shiny)
shinyServer(function(input, output) {
var <- reactive({input$var})
subsetTest <- subset(test, test$MARKET==var)
y <- subsetTest()$PRICE
x <- subsetTest()$DATE
output$ngplot <- renderPlot({
print(ggplot(data=subsetTest(), aes(x=y, y=x)) + geom_line())
})
})

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...