我想要按照应用程序名称和版本号来获取计数差异。我的数据集如下所示:app_name,version_id,count,[difference]
以下是数据集:
data = structure(list(app_name = structure(c(1L, 1L, 1L, 2L, 2L, 2L,
2L, 3L, 3L), .Label = c("a", "b", "c"), class = "factor"), version_id = c(1,
1.1, 2.3, 2, 3.1, 3.3, 4, 1.1, 2.4), count = c(600L, 620L, 620L,
200L, 200L, 250L, 250L, 15L, 36L)), .Names = c("app_name", "version_id",
"count"), class = "data.frame", row.names = c(NA, -9L))
针对这个数据框,如何根据app_name和version_id获取延迟的计数差异?每个应用程序的初始(第一个)版本差异为零,因为没有差异。
以下是使用最终“diff”列的结果示例
structure(list(app_name = structure(c(1L, 1L, 1L, 2L, 2L, 2L,
2L, 3L, 3L), .Label = c("a", "b", "c"), class = "factor"), version_id = c(1,
1.1, 2.3, 2, 3.1, 3.3, 4, 1.1, 2.4), count = c(600L, 620L, 620L,
200L, 200L, 250L, 250L, 15L, 36L), diff = c(0, 20, 0, 0, 0, 1.25,
0, 0, 2.4)), .Names = c("app_name", "version_id", "count", "diff"
), class = "data.frame", row.names = c(NA, -9L))