如何解决是否有基于R中的下拉菜单合并数据的好方法?
我一直在尝试根据下拉列表中的输入将数据与另一个数据集合并。我刚刚开始学习R,遇到了一些问题,想知道是否有更好的方法来解决这个问题。
我收到一个错误,它无法将类c(ReactiveExpr,反应性)强制转换为数据帧。
.container {
display: flex;
flex-direction: row-reverse;
text-align: center;
flex-wrap: wrap;
justify-content: flex-end;
}
.map {
width: 50%;
order: 1;
background-color: red;
}
.location-select-box {
order: 2;
width: 50%;
background-color: blue;
}
.location-listing {
order: 3;
background-color: green;
width: 50%;
}
解决方法
通常,您的方法似乎还可以。您收到的错误是来自行
eventReactive("Set1",({left_join(data_input(),annotation1,by = c("Column1" = "Column1"))}))
eventReactive
返回一个(未评估的)反应表达式,您尝试使用renderTable
将其渲染为data.frame。为了避免这种情况,您可以使用:
eventReactive("Set1",by = c("Column1" = "Column1"))}))()
但是,这里不需要eventReactive
,因为您的反应性来自input$species
(您想根据此输入更改表输出)。因此,您可以使用:
output$mergeddata <- renderTable({
if(input$species == "Set1"){
merge_data <- annotation1
} else {
merge_data <- annotation2
}
left_join(data_input(),merge_data,by = c("Column1"))
})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。