我正在尝试合并这两个反应数据集并将它们连接起来以显示表格。有什么建议?这是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)
})
错误消息:as.data.frame.default出错:无法强制类&#34; c(&#34;数据表&#34;,&#34; htmlwidget&#34;)&#34;到data.frame 堆栈跟踪(最里面的第一个): 99:as.data.frame.default 98:as.data.frame 97:没有 96:merge.data.frame 95:合并
答案 0 :(得分:2)
通过查看您的错误消息cannot coerce class "c("datatables", "htmlwidget")
,我确定您在问题中提到的其中一个数据集中意外使用DT::datatable()
。 DT::datatable()
不是您可以与其他data.frame
合并的内容。我认为您可以通过从数据集函数中删除DT::datatable()
来使代码工作。