[Swift-commit] r2139 - SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Fri Jul 18 13:18:45 CDT 2008
Author: skenny
Date: 2008-07-18 13:18:45 -0500 (Fri, 18 Jul 2008)
New Revision: 2139
Added:
SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts/permFriedmanDRAFT1.R
Log:
perm stuff
Added: SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts/permFriedmanDRAFT1.R
===================================================================
--- SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts/permFriedmanDRAFT1.R (rev 0)
+++ SwiftApps/SIDGrid/swift/projects/andric/ccf_emblem/NonParametric_lag_analy/permutations/scripts/permFriedmanDRAFT1.R 2008-07-18 18:18:45 UTC (rev 2139)
@@ -0,0 +1,34 @@
+#---- doing friedman permutations
+#---- coded Wednesday; July 2, 2008
+
+#---- this is the function used in the aggregate:
+FriedmanPerm <- function(x){
+ mm <- matrix(nrow=24,ncol=3)
+ mm[,1] = x[1:24]
+ mm[,2] = x[25:48]
+ mm[,3] = x[49:72]
+ a <- mm[1:12,sample(1:3)]
+ b <- mm[13:24,]
+ mm_shuffle <- rbind(a,b)
+ return(friedman.test(mm_shuffle)[[1]][[1]])
+}
+
+#---- Swift housekeeping:
+allinputs <- Sys.getenv("R_SWIFT_ARGS")
+print(Sys.getenv("R_SWIFT_ARGS"));
+outname <- noquote(strsplit(allinputs," ")[[1]][1])
+outname2 <- noquote(strsplit(allinputs," ")[[1]][2])
+
+inputfile <- Sys.getenv("R_INPUT")
+print(inputfile)
+Query_out <- as.matrix(read.table(inputfile))
+
+
+#---- this is where the fun begins:
+data_stack <- stack(data.frame(Query_out[,3:5]))[1]
+factors <- Query_out[,2]
+nn <- data.frame(cbind(factors,data_stack))
+m <- matrix(nrow=length(as.integer(levels(as.factor(factors)))),ncol=2)
+m[,1] <- as.integer(levels(as.factor(factors)))
+m[,2] <- aggregate(nn$values, list(nn$factors),FriedmanPerm)[,2]
+write.table(round(m,5), file=paste(outname2,outname,".txt",sep=""), row.names=FALSE, col.names=FALSE, quote=F)
More information about the Swift-commit
mailing list