Append/Join two reactive dataframes (R)

shiny

#1

I have two reactive dataframes which I am trying to append. While I do so I get the following error.

Error in ab() <- reactive(join(a(), b())) :  invalid (NULL) left side of assignment

Below is the code I am using in server.r

  a <- reactive({ MyData %>%
    filter( Primary_family == input$selected_product & Metric_name == input$selected_metric) %>%
    group_by(Month_considered) %>%
    mutate(`pct` = as.numeric(as.character(Metric_Value))*100 ) %>%
    select(Month_considered,`pct`) })

  b <-reactive({ MyData %>%
    filter(Tab == input$selected_class & Primary_family == input$selected_product) %>%
    group_by(Month_considered) %>%
    mutate(`ATC_Count` = Metric_Value) %>%
    select(Month_considered,`ATC_Count`) })

  ab() <-reactive(join(a(),b()))

#2

That should definitely work. I'd temporarily change ab to reactive({ browser(); join(a(), b()) }), and from the browser prompt, call a() to see if it is NULL or not.


#3

I thought the problem might just be the parentheses after ab (on the left side of the assignment)? In which case, this would presumably work:

ab <-reactive(join(a(),b()))

Or am I missing something? (definitely possible!)


#4

Wow, I totally missed that--I think you're right, @jcblum!