R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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 <- c(-4,-5,-6,-6,-7,-12,-16,-18,-19,-20,-24,-17,-23,-25,-24,-17,-14,-16,-13,-10,-10,-12,-12,-20,-16,-12,-14,-7,-9,-9,-4,-3,1,-1,-2,1,-3,-2,0,-2,-4,-4,-7,-9,-13,-8,-13,-15,-15,-15,-10,-12,-11,-11,-17,-18,-19,-22,-24,-24,-20,-25,-22,-17,-9,-11,-13,-11,-9,-7,-3,-3,-6,-4,-8,-1,-2,-2,-1,1,2,2,-1,1,-1,-8,1,2,-2,-2,-2,-2,-6,-4,-5) > par1 = '12' > par1 <- '12' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P. (2012), Standard Deviation-Mean Plot (v1.0.6) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_smp.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > par1 <- as.numeric(par1) > (n <- length(x)) [1] 95 > (np <- floor(n / par1)) [1] 7 > arr <- array(NA,dim=c(par1,np)) > j <- 0 > k <- 1 > for (i in 1:(np*par1)) + { + j = j + 1 + arr[j,k] <- x[i] + if (j == par1) { + j = 0 + k=k+1 + } + } > arr [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] -4 -23 -16 -3 -15 -20 -6 [2,] -5 -25 -12 -2 -15 -25 -4 [3,] -6 -24 -14 0 -10 -22 -8 [4,] -6 -17 -7 -2 -12 -17 -1 [5,] -7 -14 -9 -4 -11 -9 -2 [6,] -12 -16 -9 -4 -11 -11 -2 [7,] -16 -13 -4 -7 -17 -13 -1 [8,] -18 -10 -3 -9 -18 -11 1 [9,] -19 -10 1 -13 -19 -9 2 [10,] -20 -12 -1 -8 -22 -7 2 [11,] -24 -12 -2 -13 -24 -3 -1 [12,] -17 -20 1 -15 -24 -3 1 > arr.mean <- array(NA,dim=np) > arr.sd <- array(NA,dim=np) > arr.range <- array(NA,dim=np) > for (j in 1:np) + { + arr.mean[j] <- mean(arr[,j],na.rm=TRUE) + arr.sd[j] <- sd(arr[,j],na.rm=TRUE) + arr.range[j] <- max(arr[,j],na.rm=TRUE) - min(arr[,j],na.rm=TRUE) + } > arr.mean [1] -12.833333 -16.333333 -6.250000 -6.666667 -16.500000 -12.500000 -1.583333 > arr.sd [1] 6.978321 5.449493 5.801646 4.978743 5.036232 7.154147 3.117643 > arr.range [1] 20 15 17 15 14 22 10 > (lm1 <- lm(arr.sd~arr.mean)) Call: lm(formula = arr.sd ~ arr.mean) Coefficients: (Intercept) arr.mean 4.1133 -0.1338 > (lnlm1 <- lm(log(arr.sd)~log(arr.mean))) Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases Calls: lm -> lm.fit In addition: Warning message: In log(arr.mean) : NaNs produced Execution halted