[R] Plotting in R
Emmanuel Paradis
paradis at isem.univ-montp2.fr
Thu May 11 12:24:24 CEST 2000
At 10:03 11/05/00 +0200, you wrote:
>## I hope this is not your home work assignment;
>## The following is actually pretty neat .. (propria laus sordet)
>
>x <- 1:1000
>
>ndig <- 6
>
> (ii <- as.integer(10^(ndig-1) * log(x)))[1:7]
> (ci <- formatC(ii, flag="0", wid= ndig))[1:7]
> cm <- t(sapply(ci, function(cc) strsplit(cc,NULL)[[1]]))
> cm [1:7,]
>
>apply(cm, 2, table) #--> Nice tables
>
># The plots :
>par(mfrow= c(3,2), lab = c(10,10,7))
>for(i in 1:ndig)
> hist(as.integer(cm[,i]), breaks = -.5 + 0:10,
> main = paste("Distribution of ", i,"-th digit"))
Here is my solution (just for the tables):
x <- log(1:1000)
for (i in 1:6) print(table(as.integer((x %% (10/10^i))*10^i)))
(I'm surprised it works...)
Emmanuel Paradis
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list