【发布时间】:2023-01-24 00:37:11
【问题描述】:
【问题讨论】:
-
你只是问怎么做
sum(my_array$paying_customers ==0)?我想你会从阅读 R 入门教程中获益 -
请do not post code or data in images。在 reproducible format 中共享数据,以便我们可以复制/粘贴到 R 中进行测试。
【问题讨论】:
sum(my_array$paying_customers ==0)?我想你会从阅读 R 入门教程中获益
quux <- data.frame(year = c(rep(2017, 5), rep(2018, 4)), paying = c(0,0,1,0,2,0,0,1,1))
quux
# year paying
# 1 2017 0
# 2 2017 0
# 3 2017 1
# 4 2017 0
# 5 2017 2
# 6 2018 0
# 7 2018 0
# 8 2018 1
# 9 2018 1
table(quux$year, quux$paying > 0)
#
# FALSE TRUE
# 2017 3 2
# 2018 2 2
addmargins(table(quux$year, quux$paying > 0), 1)
#
# FALSE TRUE
# 2017 3 2
# 2018 2 2
# Sum 5 4
【讨论】: