[R] Printing a summary

darnold dwarnold45 at suddenlink.net
Fri Aug 3 22:34:41 CEST 2012


All,

Is this typical of how people will print a summary of results?

CoinTosses <- function(n) {
  x <- sample(c(0,1), n, replace=TRUE)
  y <- x
  y[y==0] <- "T"
  y[y==1] <- "H"
  numHeads <- sum(x)
  numTails <- n-sum(x)
  p <- numHeads/n
  cat(cat(y,sep=""),"\n")
  cat("Number of heads: ", numHeads, "\n")
  cat("Number of tails: ", numTails, "\n")
  cat("The proportion of heads is: ", p, "\n")
}

CoinTosses(40)

Or is another technique preferred?

Thanks.

David



--
View this message in context: http://r.789695.n4.nabble.com/Printing-a-summary-tp4639104.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list