我有以下数据:
dput(mydata)
structure(list(groupSize = structure(c(2L, 1L, 2L, 1L, 4L, 4L,
3L, 3L, 2L, 2L, 1L, 1L, 3L, 3L, 4L, 4L, 2L, 2L, 1L, 1L, 3L, 3L,
4L, 4L, 3L, 3L, 2L, 2L, 1L, 1L, 4L, 4L, 2L, 2L, 4L, 4L, 3L, 3L,
1L, 1L), .Label = c("small", "intermediate", "large", "huge"), class = "factor"),
gender = structure(c(1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L,
1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L,
1L), .Label = c("F", "M", "U"), class = "factor"), startYear = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c("2014", "2015",
"2016", "2017", "2018"), class = "factor"), count = c(7546,
3500, 5930, 7668, 18114, 13826, 11943, 10083, 147, 2791,
17158, 19389, 2063, 17901, 11007, 1660, 6660, 15198, 496,
18716, 17385, 12726, 11409, 4711, 16140, 244, 15251, 6485,
5014, 1104, 438, 10930, 15582, 15626, 2121, 6339, 135, 15432,
12263, 10607)), row.names = c(NA, -40L), class = c("data.table",
"data.frame"))
我希望能够在每个年份的每个组大小中计算男性和女性的比例。例如,在2014年,对于“小型”组大小,有45%的女性和55%的男性。如何在R中的data.table中完成此操作?