d<-read.table("D:\\Working\\Statics.txt")
df <- cbind("Q1", "Q2", "Q3", "Q4", "Q5", "Q5A", "Q5B", "Q5C", "Q5D", "Q5E", "Q5F", "Q5G", "Q6", "Q6A", "Q6B", "Q6C", "Q6D", "Q6E", "Q6F", "Q7", "Q8", "Q9") #Than you can loop through them simply by doing: result <- numeric(length(df)) for (i in 1:(length(df)-1)) { result <- chisq.test(table(df[[i]], df[[i+1]])) } and then this error comes out: Error: unexpected '}' in "}" and how can I redirect the output of the chi-square test to a file instead of console output? [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.