在renderPieChart中:数据必须由两列组成,'name'和'value'

问题描述 投票:0回答:1

我正在尝试过滤具有19列和5行的数据集。我只想要第12行和第16行,第1行和第2行。这是我的代码

dat2<-data.frame(FundingIAS2018[c(1,2),c(12,13)])
renderPieChart(div_id = "grant2017",
           data=dat2)

它给出错误:“警告:renderPieChart中的错误:数据必须由两列组成,'name'和'value'-49:stop -48:renderPieChart”

r shinydashboard
1个回答
0
投票

根据the documentationdata需要有特殊的格式。如果你输入一个data.frame,它只需要有两列,其中一列必须命名为name,另一列必须是value,后者必须是数字或整数类型。

假设您的数据格式正确,请添加一行

names(dat2) = c('name', 'value')

在你的renderPieChart命令应该解决错误之前

© www.soinside.com 2019 - 2024. All rights reserved.