Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use fivenum() instead of summary output (accurate quantiles).

  • Loading branch information...
commit b6add30cf102c272080f290291719ef12e2b0ddc 1 parent 6fe8ede
Simon Potter authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 R/chrisfns.R
10 R/chrisfns.R
View
@@ -646,6 +646,8 @@ addSumm = function(datafile, varnames, vartypes, factorLevel){
if(vartypes[1] == "CONT"){
sum.v1 = summary(v1)
values = as.vector(sum.v1)
+ # Avoid use of quantile(), as is used in summary()
+ values[c(2:3, 5)] <- fivenum(v1)[2:4]
summ.table = cbind(t(matrix(values)),signif(sd(v1),5), length(v1), deparse.level = 0)
colnames(summ.table) = c(names(sum.v1),"Std.dev", "Sample.Size")
@@ -1252,7 +1254,7 @@ showInf = function(datafile, varnames, vartypes, factorLevel){
n = length(v1)
mu = signif(mean(v1),5)
med = signif(median(v1),5)
- iqr = signif(summary(v1)[5] - summary(v1)[2],5)
+ iqr = signif(fivenum(v1)[4] - fivenum(v1)[2],5)
if(e$inferenceMethod == "Normal"){
if(n > 1){
@@ -1377,7 +1379,7 @@ showInf = function(datafile, varnames, vartypes, factorLevel){
n = length(v1)
mu = signif(mean(v1),5)
med = signif(median(v1),5)
- iqr = signif(summary(v1)[5] - summary(v1)[2],5)
+ iqr = signif(fivenum(v1)[4] - fivenum(v1)[2],5)
if(e$inferenceMethod == "Normal"){
@@ -1551,7 +1553,7 @@ showInf = function(datafile, varnames, vartypes, factorLevel){
n = length(v1.subset)
mu = signif(mean(v1.subset),5)
med = signif(median(v1.subset),5)
- iqr = signif(summary(v1.subset)[5] - summary(v1.subset)[2],5)
+ iqr = signif(fivenum(v1.subset)[4] - fivenum(v1.subset)[2],5)
if(n > bootCutoff){
@@ -2349,7 +2351,7 @@ getBoot1 = function(x, d, estimate = "mean"){
else if(estimate == "median")
return(median(x[d]))
else if(estimate == "all")
- return(c(means = mean(x[d]), medians = median(x[d]), iqrs = summary(x[d])[5] - summary(x[d])[2]))
+ return(c(means = mean(x[d]), medians = median(x[d]), iqrs = fivenum(x[d])[4] - fivenum(x[d])[2]))
}
Please sign in to comment.
Something went wrong with that request. Please try again.