【发布时间】:2023-04-06 07:31:01
【问题描述】:
我使用了一个基于以下语句返回 data.frame 的函数(工作正常!)
group <- data.frame(getGroupedData(getTweetTraining(openDBSentiment()))[getGroupedData(getTweetTraining(openDBSentiment()))$Group.2 == "test"])
我想使用的参数(输入)将其传递给数据框的过滤器会导致错误(选择未定义的列)作为结果。
getBarFrame <- function (input) {
#Build dataframe from other functions
group <- data.frame(getGroupedData(getTweetTraining(openDBSentiment())))
#Filter the data.frame based on the input parameter
group2 <- group[group$Group.2 == input ]
#select only 2 fields of the data.frame
group3 <- group2[c("Group.1","sentiment")]
#return the result tot the function
return (group3)
}
你知道如何解决这个问题
【问题讨论】:
-
把它变成多行,将中间结果保存到不同的变量中,你就会很好地了解实际发生了什么以及问题发生在哪一步。
-
谢谢,劳里克。它可以解决这个特殊的问题。