Для определенного фрейма данных, который у меня есть, необходимо распределить определенное количество (POT) по фрейму данных.Когда эта сумма исчерпана, она должна вернуть оставшийся кадр данных без присвоения значения.Введите DF:
Accepted Jackpot Commision Rank
NO 2760.33 279.85 1
NO 2760.33 279.85 1
NO 2760.33 279.85 1
NO 2760.33 279.85 1
NO 2760.33 206.38 2
NO 2760.33 206.38 2
NO 2760.33 206.38 2
, как вы можете видеть, DF имеет 4 столбца, но в действительности он намного больше, но это столбцы, которые имеют значение.Я хочу изменить «Принято» на «Да» при истощении джекпота с комиссией, основанной на столбце «Ранг».
Таким образом, джекпот - комиссия (2760,33 - 279,85 = 2480,48) превращается в «Да» для всех рядов, имеющих ранг 1. Джекпот теперь: 2480.48.Так что это то, что мы можем использовать для ранга 2 и так далее.До тех пор, пока мы не достигнем 0 и просто все принятые останутся на NO.
Accepted Jackpot Commision Rank
YES 2760.33 279.85 1
YES 2760.33 279.85 1
YES 2760.33 279.85 1
YES 2760.33 279.85 1
NO 2480.48 206.38 2
NO 2480.48 206.38 2
NO 2480.48 206.38 2
Я пробовал много вещей, таких как By, (s)apply, for, aggregate
и даже больше, но мне не удалось получить правильный ответ.Любая помощь приветствуется.
Полный кадр данных теста:
dput(tst_df)
structure(list(Accepted = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 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1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("NO", "YES"), class = "factor"),
Jackpot = c(2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33, 2760.33,
2760.33, 2760.33, 2760.33, 2760.33, 2760.33), Commision = c(12.71,
12.71, 12.71, 27.52, 27.52, 27.52, 27.52, 27.52, 16.94, 16.94,
16.94, 31.51, 31.51, 31.51, 31.51, 31.51, 3.72, 3.72, 16.68,
16.68, 16.68, 14.46, 14.46, 132.13, 132.13, 132.13, 132.13,
132.13, 132.13, 132.13, 132.13, 132.13, 132.13, 132.13, 132.13,
132.13, 132.13, 132.13, 132.13, 132.13, 132.13, 132.13, 132.13,
132.13, 132.13, 132.13, 132.13, 12.19, 12.19, 6.82, 6.82,
55.31, 55.31, 55.31, 55.31, 55.31, 55.31, 55.31, 13.01, 13.01,
155.8, 155.8, 155.8, 155.8, 155.8, 155.8, 155.8, 155.8, 155.8,
155.8, 155.8, 155.8, 155.8, 155.8, 155.8, 155.8, 155.8, 155.8,
155.8, 155.8, 155.8, 155.8, 155.8, 155.8, 155.8, 155.8, 155.8,
155.8, 155.8, 155.8, 279.85, 279.85, 279.85, 279.85, 279.85,
279.85, 279.85, 279.85, 279.85, 279.85, 279.85, 279.85, 279.85,
279.85, 279.85, 279.85, 279.85, 279.85, 279.85, 279.85, 279.85,
279.85, 279.85, 279.85, 279.85, 279.85, 279.85, 279.85, 279.85,
279.85, 279.85, 279.85, 279.85, 279.85, 279.85, 279.85, 279.85,
279.85, 279.85, 279.85, 279.85, 279.85, 1.86, 6.2, 6.2, 36.96,
36.96, 36.96, 36.96, 36.96, 36.96, 36.96, 36.96, 36.96, 9.3,
6.45, 8.26, 10.16, 10.16, 10.16, 10.16, 6.61, 5.78, 6.2,
18.59, 18.59, 18.59, 84.24, 84.24, 84.24, 84.24, 84.24, 84.24,
84.24, 84.24, 84.24, 84.24, 84.24, 31.19, 31.19, 31.19, 31.19,
31.19, 31.19, 167.78, 167.78, 167.78, 167.78, 167.78, 167.78,
167.78, 167.78, 167.78, 167.78, 167.78, 167.78, 167.78, 167.78,
167.78, 167.78, 167.78, 167.78, 167.78, 167.78, 167.78, 167.78,
167.78, 167.78, 167.78, 167.78, 167.78, 167.78, 167.78, 1.24,
3.81, 3.81, 4.13, 17.67, 17.67, 17.67, 17.67, 106.72, 106.72,
106.72, 106.72, 106.72, 106.72, 106.72, 106.72, 106.72, 106.72,
106.72, 106.72, 106.72, 106.72, 106.72, 106.72, 106.72, 9.3,
55.43, 55.43, 55.43, 55.43, 55.43, 55.43, 55.43, 2.23, 24.79,
24.79, 24.79, 24.79, 260.22, 260.22, 260.22, 260.22, 260.22,
260.22, 260.22, 260.22, 260.22, 260.22, 260.22, 260.22, 260.22,
260.22, 260.22, 260.22, 260.22, 260.22, 260.22, 260.22, 260.22,
260.22, 260.22, 260.22, 260.22, 260.22, 260.22, 260.22, 260.22,
260.22, 260.22, 3.51, 3.51, 3.51, 7.44, 4.29, 4.29, 6.61,
27.58, 27.58, 27.58, 27.58, 27.58, 27.58, 27.58, 115.08,
115.08, 115.08, 115.08, 115.08, 115.08, 115.08, 115.08, 115.08,
115.08, 115.08, 115.08, 115.08, 115.08, 115.08, 115.08, 206.38,
206.38, 206.38, 206.38, 206.38, 206.38, 206.38, 206.38, 206.38,
206.38, 206.38, 206.38, 206.38, 206.38, 206.38, 206.38, 206.38,
206.38, 206.38, 206.38, 206.38, 206.38, 206.38, 206.38, 206.38,
206.38, 206.38, 206.38, 206.38, 206.38, 206.38, 206.38, 206.38,
206.38, 206.38, 206.38, 69.1, 69.1, 69.1, 69.1, 69.1, 69.1,
69.1, 69.1, 69.1, 69.1, 69.1, 69.1, 69.1, 4.63, 0, 6.69,
6.69, 6.69, 6.69, 66.85, 66.85, 66.85, 66.85, 66.85, 66.85,
66.85, 66.85, 66.85, 11.98), Rank = c(15L, 15L, 15L, 18L,
18L, 18L, 18L, 18L, 37L, 37L, 37L, 25L, 25L, 25L, 25L, 25L,
33L, 33L, 20L, 20L, 20L, 23L, 23L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 38L, 38L, 58L, 58L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 70L, 70L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 22L, 47L, 47L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 85L, 53L, 60L, 35L, 35L, 35L, 35L, 34L, 48L, 54L,
41L, 41L, 41L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 17L, 17L, 17L, 17L, 17L, 17L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 42L, 31L, 31L, 32L, 21L,
21L, 21L, 21L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 13L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 30L, 43L, 43L, 43L, 43L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 66L, 66L, 66L, 79L, 45L,
45L, 46L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 104L, 26L, 29L, 29L, 29L, 29L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 57L)), .Names = c("Accepted", "Jackpot",
"Commision", "Rank"), row.names = c(NA, -367L), class = "data.frame")