Several pairwise t-tests in R (with Bonferroni correction)

109 Views Asked by At

I'm running an experiment where participants have to rate several different scents on different dimensions. Below is an example of my data. In other words, participants are rating scent A on four dimensions, then they evaluate scent B on the same dimensions, followed by scent C.


A_pleasant <-c(4,5,4,6,7,5,5,4,4,1,5,6)
A_complex <-c(1,1,2,3,2,2,1,2,1,4,2,3)
A_familiar <-c(7,7,7,6,7,5,7,5,7,5,5,2)
A_relaxing <-c(4,5,4,6,3,4,2,4,5,2,5,5)
B_pleasant <-c(4,5,7,6,7,5,5,7,7,2,5,6)
B_complex <-c(3,3,3,2,3,5,1,3,2,3,3,3)
B_familiar <-c(6,6,6,4,3,4,3,4,7,6,5,6)
B_relaxing <-c(4,4,4,3,3,3,4,3,5,2,5,2)
C_pleasant <-c(1,1,1,2,2,1,2,1,4,1,2,1)
C_complex <-c(2,2,2,2,2,3,1,1,1,2,1,3)
C_familiar <-c(1,1,2,1,4,3,4,2,1,2,1,2)
C_relaxing <-c(2,2,2,2,2,1,1,1,1,1,2,2)

df <-data.frame(A_pleasant,A_complex,A_familiar,A_relaxing,B_pleasant,B_complex,B_familiar,B_relaxing,C_pleasant,C_complex,C_familiar,C_relaxing)
df

I'm interested in running within-subjects t-tests, with Bonferroni corrections for multiple comparisons, to see where the differences lie between these scents. E.g., I want to know which scents are significantly different in terms of pleasantness.

How can I run this on R? Is my data set up appropriately, or do I need to group the variables somehow?

Thank you!

I've used t.test on R but I'm not sure how to run this test with several samples, nor how to correct for multiple comparisons.

0

There are 0 best solutions below