您如何获得具有某些属性 dplyr 的所有响应的计数(数量)

How do you get a count (the number of) of all responses with certain attributes dplyr

现在我的代码如下所示:

Data <- Other_Data %>%
  dplyr::filter(Description == "Information" & Category == 1 & Cost >= 1000)

它创建了一个新的 table,它确实给了我观察的计数,它确实回答了我正在回答的问题。但是,我想知道是否有一种方法可以简单地打印数字。

我们可以使用sum

with(Other_Data, sum(Description == "Information" & 
           Category == 1 & Cost >= 1000, na.rm = TRUE))

您在 Data 中有所需的数据。为了得到它的计数,你可以做 nrow(Data) 这将计算 Data 中的行数和 return 满足 filter.

中的条件的计数