1

I am trying to merge these two reactive datasets and join them to display a table. Any advice? Here is the code in server.R:

  dataset1 <- reactive({
    result <- custom_function_call(*params in here*)
  })
    dataset2 <- reactive({
    result <- custom_function_call_v2(*params in here*)
  })




    joined_dataset <- reactive({
     result<-merge(x = dataset1(), y = dataset2(), by = "UniqueID", all = TRUE)

      result<-
        result%>%
        mutate(*dyplr code to create new cols here*)

        return(result)
        })

  output$summaryTableName <- 
    DT::renderDataTable({
      res <- joined_dataset()


      return(res)

    }) 

Error message: Error in as.data.frame.default: cannot coerce class "c("datatables", "htmlwidget")" to a data.frame Stack trace (innermost first): 99: as.data.frame.default 98: as.data.frame 97: nrow 96: merge.data.frame 95: merge

zelda26
  • 489
  • 2
  • 10
  • 33
  • Try printing `class(custom_function_call_v2(*params in here*))` and `class(custom_function_call_v2(*params in here*))` – Deena Apr 29 '18 at 11:47
  • Assuming `dataset1` and `dataset2` actually return `data.frames` your code looks correct but there's no more we can do without a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – mlegge Apr 30 '18 at 00:27

1 Answers1

2

By looking at your error message cannot coerce class "c("datatables", "htmlwidget"), I'm sure that you accidently use DT::datatable() in one of the datasets as mentioned in the question. The DT::datatable() is not something you can merge with another data.frame. I think you can get your codes work by removing the DT::datatable() from the dataset functions.

Shrek Tan
  • 2,793
  • 8
  • 14