I have a dataset containing experiment data. Every day I have a new observation.
A fictional example of my df with columns: day: day group a: data management group b: data processing.
structure(list(day = c(1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), group_a = c(4L,
2L, 3L, 1L, 1L, 4L, 3L, 2L, 4L), group_b = c(3L, 4L, 2L, 2L,
2L, 2L, 3L, 4L, 5L)), .Names = c("day", "group_a", "group_b"), class = "data.frame", row.names = c(NA,
-9L))
I want to multiply this dataset, apply the rank criteria signed by wilcoxon, for example:
test <- wilcox.test(df$group_a, df$group_b, alternative = 'g')
test$p.value
In this example, I apply the test across the entire dataset.
I want to apply it on the 1st day, then the 1st and 2nd, etc., finally getting a list similar to (fictitious data):
day p-value
1 0.02
2 0.03
3 0.3
How can I apply the test in a for loop for a "day", but in a "cumulative" number of days?