First I would like to apologise in advance. I am new to programming so my questions might be obvious and/or naive.
I am running a two sided Kolmogorov–Smirnov test on 26 columns of data using the code below:
#a bit of the data
library("dgof")
df1 <- data.frame(a = c(0,0.324675325,0.324675325,2.272727273,1.298701299,2.922077922,2.922077922,4.545454545,4.545454545,3.896103896,5.194805195),
b = c(0.110619469,0.110619469,0,0.221238938,0.884955752,2.654867257,3.761061947,5.752212389,5.19),
cc = c(0.110619469,0.110619469,0,0.221238938,0.884955752,2.654867257,3.761061947,5.752212389,5.19),
d = c(0,0,0,0,1.550387597,1.162790698,5.426356589,5.03875969,2.325581395,2.325581395,3.488372093,5.813953488,3.100775194,5.426356589,6.589147287,5.426356589,3.875968992,5.426356589))
df2 <- data.frame(a = c(0,0.324675325,0.324675325,2.272727273,1.298701299,2.922077922,2.922077922,4.545454545,4.545454545,3.896103896,5.194805195),
b = c(0.110619469,0.110619469,0,0.221238938,0.884955752,2.654867257,3.761061947,5.752212389,5.19),
cc = c(0.110619469,0.110619469,0,0.221238938,0.884955752,2.654867257,3.761061947,5.752212389,5.19),
d = c(0,0,0,0,1.550387597,1.162790698,5.426356589,5.03875969,2.325581395,2.325581395,3.488372093,5.813953488,3.100775194,5.426356589,6.589147287,5.426356589,3.875968992,5.426356589))
for(i in 1:(ncol(df1)-2)){
for(j in (i+1):(ncol(df2)-1)){
print(paste0("Trial.", i, " - Trial.", j))
ks_result <- ks.test(df1[, i],
df2[, j],
alternative="two.sided")
print(ks_result)
}
}
(df1 and df2 contain the exact same data - this is the only way I could find of getting the ks.test to compare all data)
I would like to put all of the results into a data.frame but I have no idea where to even start with this.
I really appreciate any help you can give in putting the results into a table (preferably by keeping as much of the code I have.
Thanks