I have a dataframe like this:
df1 <- data.frame(
id_val = c('row1', 'row2', 'row3'),
value_florida = c(10, 27, 16),
value_illinois = c(17, 14, 22),
value_vermont = c(11, 4, 29),
base_florida = c(12, 44, 32),
base_illinois = c(18, 29, 23),
base_vermont = c(15, 8, 33)
)
I want to run prop.test on every combination of value and base columns such that I will know the significance of each row's pair against one another. Manually I would do this for the first pair, Row 1 Florida versus Row 1 Illinois:
tmp <- prop.test(x = c(10, 17), n = c(12, 18))
tmp$p.value
But then I'd like to move to the next pair, Row 1 Florida versus Row 1 Vermont. And then Row 1 Illinois versus Row 1 Vermont. Then on to the Row 2 pairs. And on and on.
Is there a way to achieve this in R, ideally using the purrr library?