mahagadorn / r-intro-mahagadorn

r-intro-mahagadorn created by GitHub Classroom
0 stars 0 forks source link

Lesson 4. Question2 #11

Closed mahagadorn closed 8 years ago

mahagadorn commented 8 years ago

mah.summary <- function(x){
  sum.output <- matrix(NA, nrow = ncol(x), ncol = 6)      #preallocating data matrix
  sum.output[,1] <- apply(x, 2, sum)
  sum.output[,2] <- apply(x, 2, mean)
  sum.output[,3] <- apply(x, 2, sd)
  sum.output[,4] <- apply(x, 2, min)
  sum.output[,5] <- apply(x, 2, max)
  sum.output[,6] <- apply(x, 2, class)    #added class for inclusion in function that takes both types of data
  colnames(sum.output) <- c("sum", "mean", "std.dev", "minimum", "maximum", "class")
  plot <- barplot(sum.output[,"mean"])
  axis(1, tick=TRUE, pos = -0.2, lty = 1)
  return(noquote(sum.output))
}

 Error in -0.01 * height : non-numeric argument to binary operator