R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- array(list(23 + ,17 + ,23 + ,4 + ,24 + ,17 + ,20 + ,4 + ,22 + ,18 + ,20 + ,6 + ,20 + ,21 + ,21 + ,8 + ,24 + ,20 + ,24 + ,8 + ,27 + ,28 + ,22 + ,4 + ,28 + ,19 + ,23 + ,4 + ,27 + ,22 + ,20 + ,8 + ,24 + ,16 + ,25 + ,5 + ,23 + ,18 + ,23 + ,4 + ,24 + ,25 + ,27 + ,4 + ,27 + ,17 + ,27 + ,4 + ,27 + ,14 + ,22 + ,4 + ,28 + ,11 + ,24 + ,4 + ,27 + ,27 + ,25 + ,4 + ,23 + ,20 + ,22 + ,8 + ,24 + ,22 + ,28 + ,4 + ,28 + ,22 + ,28 + ,4 + ,27 + ,21 + ,27 + ,4 + ,25 + ,23 + ,25 + ,8 + ,19 + ,17 + ,16 + ,4 + ,24 + ,24 + ,28 + ,7 + ,20 + ,14 + ,21 + ,4 + ,28 + ,17 + ,24 + ,4 + ,26 + ,23 + ,27 + ,5 + ,23 + ,24 + ,14 + ,4 + ,23 + ,24 + ,14 + ,4 + ,20 + ,8 + ,27 + ,4 + ,11 + ,22 + ,20 + ,4 + ,24 + ,23 + ,21 + ,4 + ,25 + ,25 + ,22 + ,4 + ,23 + ,21 + ,21 + ,4 + ,18 + ,24 + ,12 + ,15 + ,20 + ,15 + ,20 + ,10 + ,20 + ,22 + ,24 + ,4 + ,24 + ,21 + ,19 + ,8 + ,23 + ,25 + ,28 + ,4 + ,25 + ,16 + ,23 + ,4 + ,28 + ,28 + ,27 + ,4 + ,26 + ,23 + ,22 + ,4 + ,26 + ,21 + ,27 + ,7 + ,23 + ,21 + ,26 + ,4 + ,22 + ,26 + ,22 + ,6 + ,24 + ,22 + ,21 + ,5 + ,21 + ,21 + ,19 + ,4 + ,20 + ,18 + ,24 + ,16 + ,22 + ,12 + ,19 + ,5 + ,20 + ,25 + ,26 + ,12 + ,25 + ,17 + ,22 + ,6 + ,20 + ,24 + ,28 + ,9 + ,22 + ,15 + ,21 + ,9 + ,23 + ,13 + ,23 + ,4 + ,25 + ,26 + ,28 + ,5 + ,23 + ,16 + ,10 + ,4 + ,23 + ,24 + ,24 + ,4 + ,22 + ,21 + ,21 + ,5 + ,24 + ,20 + ,21 + ,4 + ,25 + ,14 + ,24 + ,4 + ,21 + ,25 + ,24 + ,4 + ,12 + ,25 + ,25 + ,5 + ,17 + ,20 + ,25 + ,4 + ,20 + ,22 + ,23 + ,6 + ,23 + ,20 + ,21 + ,4 + ,23 + ,26 + ,16 + ,4 + ,20 + ,18 + ,17 + ,18 + ,28 + ,22 + ,25 + ,4 + ,24 + ,24 + ,24 + ,6 + ,24 + ,17 + ,23 + ,4 + ,24 + ,24 + ,25 + ,4 + ,24 + ,20 + ,23 + ,5 + ,28 + ,19 + ,28 + ,4 + ,25 + ,20 + ,26 + ,4 + ,21 + ,15 + ,22 + ,5 + ,25 + ,23 + ,19 + ,10 + ,25 + ,26 + ,26 + ,5 + ,18 + ,22 + ,18 + ,8 + ,17 + ,20 + ,18 + ,8 + ,26 + ,24 + ,25 + ,5 + ,28 + ,26 + ,27 + ,4 + ,21 + ,21 + ,12 + ,4 + ,27 + ,25 + ,15 + ,4 + ,22 + ,13 + ,21 + ,5 + ,21 + ,20 + ,23 + ,4 + ,25 + ,22 + ,22 + ,4 + ,22 + ,23 + ,21 + ,8 + ,23 + ,28 + ,24 + ,4 + ,26 + ,22 + ,27 + ,5 + ,19 + ,20 + ,22 + ,14 + ,25 + ,6 + ,28 + ,8 + ,21 + ,21 + ,26 + ,8 + ,13 + ,20 + ,10 + ,4 + ,24 + ,18 + ,19 + ,4 + ,25 + ,23 + ,22 + ,6 + ,26 + ,20 + ,21 + ,4 + ,25 + ,24 + ,24 + ,7 + ,25 + ,22 + ,25 + ,7 + ,22 + ,21 + ,21 + ,4 + ,21 + ,18 + ,20 + ,6 + ,23 + ,21 + ,21 + ,4 + ,25 + ,23 + ,24 + ,7 + ,24 + ,23 + ,23 + ,4 + ,21 + ,15 + ,18 + ,4 + ,21 + ,21 + ,24 + ,8 + ,25 + ,24 + ,24 + ,4 + ,22 + ,23 + ,19 + ,4 + ,20 + ,21 + ,20 + ,10 + ,20 + ,21 + ,18 + ,8 + ,23 + ,20 + ,20 + ,6 + ,28 + ,11 + ,27 + ,4 + ,23 + ,22 + ,23 + ,4 + ,28 + ,27 + ,26 + ,4 + ,24 + ,25 + ,23 + ,5 + ,18 + ,18 + ,17 + ,4 + ,20 + ,20 + ,21 + ,6 + ,28 + ,24 + ,25 + ,4 + ,21 + ,10 + ,23 + ,5 + ,21 + ,27 + ,27 + ,7 + ,25 + ,21 + ,24 + ,8 + ,19 + ,21 + ,20 + ,5 + ,18 + ,18 + ,27 + ,8 + ,21 + ,15 + ,21 + ,10 + ,22 + ,24 + ,24 + ,8 + ,24 + ,22 + ,21 + ,5 + ,15 + ,14 + ,15 + ,12 + ,28 + ,28 + ,25 + ,4 + ,26 + ,18 + ,25 + ,5 + ,23 + ,26 + ,22 + ,4 + ,26 + ,17 + ,24 + ,6 + ,20 + ,19 + ,21 + ,4 + ,22 + ,22 + ,22 + ,4 + ,20 + ,18 + ,23 + ,7 + ,23 + ,24 + ,22 + ,7 + ,22 + ,15 + ,20 + ,10 + ,24 + ,18 + ,23 + ,4 + ,23 + ,26 + ,25 + ,5 + ,22 + ,11 + ,23 + ,8 + ,26 + ,26 + ,22 + ,11 + ,23 + ,21 + ,25 + ,7 + ,27 + ,23 + ,26 + ,4 + ,23 + ,23 + ,22 + ,8 + ,21 + ,15 + ,24 + ,6 + ,26 + ,22 + ,24 + ,7 + ,23 + ,26 + ,25 + ,5 + ,21 + ,16 + ,20 + ,4 + ,27 + ,20 + ,26 + ,8 + ,19 + ,18 + ,21 + ,4 + ,23 + ,22 + ,26 + ,8 + ,25 + ,16 + ,21 + ,6 + ,23 + ,19 + ,22 + ,4 + ,22 + ,20 + ,16 + ,9 + ,22 + ,19 + ,26 + ,5 + ,25 + ,23 + ,28 + ,6 + ,25 + ,24 + ,18 + ,4 + ,28 + ,25 + ,25 + ,4 + ,28 + ,21 + ,23 + ,4 + ,20 + ,21 + ,21 + ,5 + ,25 + ,23 + ,20 + ,6 + ,19 + ,27 + ,25 + ,16 + ,25 + ,23 + ,22 + ,6 + ,22 + ,18 + ,21 + ,6 + ,18 + ,16 + ,16 + ,4) + ,dim=c(4 + ,161) + ,dimnames=list(c('Q2' + ,'Q9' + ,'Q16' + ,'Q23') + ,1:161)) > y <- array(NA,dim=c(4,161),dimnames=list(c('Q2','Q9','Q16','Q23'),1:161)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par1 = '1 2 3 4 5 6 7' > docor <- function(x,y,method) { + r <- cor.test(x,y,method=method) + paste(round(r$estimate,3),' (',round(r$p.value,3),')',sep='') + } > x <- t(x) > nx <- length(x[,1]) > cx <- length(x[1,]) > mymedian <- median(as.numeric(strsplit(par1,' ')[[1]])) > myresult <- array(NA, dim = c(cx,7)) > rownames(myresult) <- paste('Q',1:cx,sep='') > colnames(myresult) <- c('mean','Sum of
positives (Ps)','Sum of
negatives (Ns)', '(Ps-Ns)/(Ps+Ns)', 'Count of
positives (Pc)', 'Count of
negatives (Nc)', '(Pc-Nc)/(Pc+Nc)') > for (i in 1:cx) { + spos <- 0 + sneg <- 0 + cpos <- 0 + cneg <- 0 + for (j in 1:nx) { + if (!is.na(x[j,i])) { + myx <- as.numeric(x[j,i]) - mymedian + if (myx > 0) { + spos = spos + myx + cpos = cpos + 1 + } + if (myx < 0) { + sneg = sneg + abs(myx) + cneg = cneg + 1 + } + } + } + myresult[i,1] <- round(mean(as.numeric(x[,i]),na.rm=T)-mymedian,2) + myresult[i,2] <- spos + myresult[i,3] <- sneg + myresult[i,4] <- round((spos - sneg) / (spos + sneg),2) + myresult[i,5] <- cpos + myresult[i,6] <- cneg + myresult[i,7] <- round((cpos - cneg) / (cpos + cneg),2) + } > myresult mean Sum of
positives (Ps) Sum of
negatives (Ns) (Ps-Ns)/(Ps+Ns) Q1 19.06 3068 0 1 Q2 16.59 2671 0 1 Q3 18.42 2966 0 1 Q4 1.81 291 0 1 Count of
positives (Pc) Count of
negatives (Nc) (Pc-Nc)/(Pc+Nc) Q1 161 0 1 Q2 161 0 1 Q3 161 0 1 Q4 84 0 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Summary of survey scores (median of Likert score was subtracted)',8,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Question',header=TRUE) > for (i in 1:7) { + a<-table.element(a,colnames(myresult)[i],header=TRUE) + } > a<-table.row.end(a) > for (i in 1:cx) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + for (j in 1:7) { + a<-table.element(a,myresult[i,j],align='right') + } + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/1fjir1318661208.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Pearson correlations of survey scores (and p-values)',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'',header=TRUE) > a<-table.element(a,'mean',header=TRUE) > a<-table.element(a,'(Ps-Ns)/(Ps+Ns)',header=TRUE) > a<-table.element(a,'(Pc-Nc)/(Pc+Nc)',header=TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'mean',header=TRUE) > a<-table.element(a,docor(myresult[,1],myresult[,1],method='pearson'),align='right') > a<-table.element(a,docor(myresult[,1],myresult[,4],method='pearson'),align='right') Warning message: In cor(x, y) : the standard deviation is zero > a<-table.element(a,docor(myresult[,1],myresult[,7],method='pearson'),align='right') Warning message: In cor(x, y) : the standard deviation is zero > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'(Ps-Ns)/(Ps+Ns)',header=TRUE) > a<-table.element(a,docor(myresult[,4],myresult[,1],method='pearson'),align='right') Warning message: In cor(x, y) : the standard deviation is zero > a<-table.element(a,docor(myresult[,4],myresult[,4],method='pearson'),align='right') Warning message: In cor(x, y) : the standard deviation is zero > a<-table.element(a,docor(myresult[,4],myresult[,7],method='pearson'),align='right') Warning message: In cor(x, y) : the standard deviation is zero > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'(Pc-Nc)/(Pc+Nc)',header=TRUE) > a<-table.element(a,docor(myresult[,7],myresult[,1],method='pearson'),align='right') Warning message: In cor(x, y) : the standard deviation is zero > a<-table.element(a,docor(myresult[,7],myresult[,4],method='pearson'),align='right') Warning message: In cor(x, y) : the standard deviation is zero > a<-table.element(a,docor(myresult[,7],myresult[,7],method='pearson'),align='right') Warning message: In cor(x, y) : the standard deviation is zero > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/2uz5c1318661208.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Kendall tau rank correlations of survey scores (and p-values)',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'',header=TRUE) > a<-table.element(a,'mean',header=TRUE) > a<-table.element(a,'(Ps-Ns)/(Ps+Ns)',header=TRUE) > a<-table.element(a,'(Pc-Nc)/(Pc+Nc)',header=TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'mean',header=TRUE) > a<-table.element(a,docor(myresult[,1],myresult[,1],method='kendall'),align='right') > a<-table.element(a,docor(myresult[,1],myresult[,4],method='kendall'),align='right') Warning message: In cor(x, y, method = "kendall") : the standard deviation is zero > a<-table.element(a,docor(myresult[,1],myresult[,7],method='kendall'),align='right') Warning message: In cor(x, y, method = "kendall") : the standard deviation is zero > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'(Ps-Ns)/(Ps+Ns)',header=TRUE) > a<-table.element(a,docor(myresult[,4],myresult[,1],method='kendall'),align='right') Warning message: In cor(x, y, method = "kendall") : the standard deviation is zero > a<-table.element(a,docor(myresult[,4],myresult[,4],method='kendall'),align='right') Warning message: In cor(x, y, method = "kendall") : the standard deviation is zero > a<-table.element(a,docor(myresult[,4],myresult[,7],method='kendall'),align='right') Warning message: In cor(x, y, method = "kendall") : the standard deviation is zero > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'(Pc-Nc)/(Pc+Nc)',header=TRUE) > a<-table.element(a,docor(myresult[,7],myresult[,1],method='kendall'),align='right') Warning message: In cor(x, y, method = "kendall") : the standard deviation is zero > a<-table.element(a,docor(myresult[,7],myresult[,4],method='kendall'),align='right') Warning message: In cor(x, y, method = "kendall") : the standard deviation is zero > a<-table.element(a,docor(myresult[,7],myresult[,7],method='kendall'),align='right') Warning message: In cor(x, y, method = "kendall") : the standard deviation is zero > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/3qalk1318661208.tab") > > > > proc.time() user system elapsed 0.325 0.034 0.352