I am trying to perform a paired permutation t-test. I get an error " in t.star[r, ] <- res[[r]] : incorrect number of subscripts on matrix". Below is the code I wrote. Any pointers appreciated.
library(RVAideMemoire)
library(boot)
library(xlsx)
mydata <- read.xlsx("C:/data_bootstrap.xlsx",1)
results = boot(mydata,statistic=sample_mean,R=500)
print (results)
sample_mean <- function(mydata, indices) {
sam=mydata[indices,1]
sam1=mydata[indices,2]
bar = perm.t.test(sam,sam1,paired=TRUE,nperm=500)
return(bar)
}
Raw data, no need for the link:
structure(list(Random = c(11L, 10L, 11L, 11L, 10L, 10L, 36L, 11L, 10L, 16L, 16L, 10L, 16L, 10L, 16L, 10L, 11L, 11L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 10L, 10L, 10L, 11L), Statement = c(11L, 10L, 11L, 10L, 10L, 16L, 16L, 10L, 10L, 16L, 11L, 11L, 10L, 10L, 16L, 11L, 10L, 11L, 16L, 10L, 11L, 10L, 16L, 10L, 10L, 10L, 11L, 10L, 10L)), class = "data.frame", row.names = c(NA, -29L))