[英]R Shiny: merge two reactive datasets and display in table with DT
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: 这是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 错误消息:as.data.frame.default中的错误:无法将类“ c(” datatables“,” htmlwidget“)”强制转换为data.frame堆栈跟踪(从最里面开始):99:as.data.frame.default 98 :as.data.frame 97:nrow 96:merge.data.frame 95:merge
通过查看您的错误信息cannot coerce class "c("datatables", "htmlwidget")
我敢肯定,你不小心使用DT::datatable()
中的数据集作为一个在问题中提到,该DT::datatable()
不能与另一个data.frame
合并,我认为可以通过从数据集函数中删除DT::datatable()
来使代码正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.