I have a data frame with many columns. The first column contains categories such as "System 1", "System 2", and the second column has numbers that represent the 0's and 1's. Please see below :
For example:
| SYSTEM | Q1 | Q2 |
|---|---|---|
| System 1 | 0 | 1 |
| System 1 | 1 | 0 |
| System 2 | 1 | 1 |
| System 2 | 0 | 0 |
| System 2 | 1 | 1 |
How to write R code to run a paired Wilcoxon test for multiple columns from 1 to 100 using a for loop or other recommended solutions.
Here is my data
x<-"SYSTEM Q1 Q2 Q3 Q4 Q5
S1 0 1 0 0 0
S1 1 0 1 1 1
S2 1 1 1 1 1
S2 0 0 1 1 0
S2 1 1 0 0 0"
mydata <- read.table(textConnection(x), header = TRUE)
n <- 1e4
df2 <- data.frame(
SYSTEM = sample(mydata$SYSTEM, n, TRUE),
Q1 = sample(mydata$Q1, n, TRUE),
Q2 = sample(mydata$Q2, n, TRUE),
Q3 = sample(mydata$Q3, n, TRUE),
Q4 = sample(mydata$Q4, n, TRUE),
Q5 = sample(mydata$Q5, n, TRUE)
)