请参见here输入和所需的输出表。
我有一个数据集(df_report),如下所示:
city <- c("New York","Mexico City","Cape Town")
A <- c(3,4,1)
B <- c(5,1,3)
C <- c(0,3,2)
category <- c("Complete","Incomplete","Complete")
df_report <- data.frame(city, category, A, B, C)
然后是变量的逻辑/公式:
RB_1 <- df_report["Complete","A"] + df_report["Complete","B"]
RB_2 <- sum(df_report["Incomplete",]) - df_report["Incomplete","C"]
RB_3 <- sum(df_report["Complete",])
RB_4 <- RB_1 + RB_2
如何使用以下内容制作单独的数据集?行标题:变量;列:城市