0

This seems like it should be very simple but I just can't wrap my mind around it. Other questions/examples on here have dozens of variables, and I only have two, so I've been trying to figure out how to adapt them to my data but to no avail.

df <- data.frame(month = month.abb, amount.x = runif(12), amount.y = runif(12))

I want to run 12 t-tests, one for each month. The ideal output would be 12 p-values, or at the very least a list of 12 so I can see the results of each test. I've tried various forms of map() and it keeps either throwing errors or just comparing each amount variable to itself instead of comparing each pair.

Any help would be appreciated!

  • have you tried the solutions in this question? https://stackoverflow.com/questions/42609694/perform-multiple-paired-t-tests-based-on-groups-categories – StupidWolf Nov 21 '20 at 23:30
  • 1
    You can't run 12 t-tests. You have two observations in each month (one in each column). It doesn't make sense to try to do a t-test of a single value against a single value. Or am I misunderstanding what you are asking? – Allan Cameron Nov 21 '20 at 23:32
  • @StupidWolf that solution worked! Now I feel very silly that my search terms didn't bring that one up and only gave me more complicated examples. Thank you! – user14517212 Nov 21 '20 at 23:36
  • note Allan Cameron's comment. Make sure one have more than 1 observation per group for each month – StupidWolf Nov 21 '20 at 23:46

0 Answers0