[R] Interactive plot (histogram) in R..........possible?
Greg Snow
Greg.Snow at imail.org
Wed Feb 17 05:12:45 CET 2010
This can be done fairly simply using the tkexamp function from the TeachingDemos package.
Here are some examples:
library(TeachingDemos)
histfunc <- function(n, mu=0, sigma=1) {
x <- rnorm(n, mu, sigma)
hist(x)
}
hist.list1 <- list( n=list('slider', from=10, to=10000, resolution=10),
mu=list('numentry', init=0), sigma=list('numentry', init=1) )
tkexamp( histfunc, hist.list1 )
### maybe better
hist.list2 <- list( n=list('spinbox', values=c(10,50,100,500,1000,5000,10000),
init=10, from=10, to=10000))
tkexamp( histfunc, hist.list2 )
# another variation
x <- rnorm(10000)
histfunc2 <- function(n) {
hist(x[seq_len(n)])
}
tkexamp( histfunc2,
list( n=list('slider', from=10, to=10000, resolution=10) ) )
You may want to set some of the other arguments as well.
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Megh
> Sent: Tuesday, February 16, 2010 2:44 PM
> To: r-help at r-project.org
> Subject: [R] Interactive plot (histogram) in R..........possible?
>
>
> Dear all,
>
> I am looking for some kind of interactive plot to draw a histogram for
> a
> normal distribution with different sample size. In that plot there
> would be
> some sort of "scroll-bar" which will take min value 10 and maximum
> value of
> 10,000 as sample size (n) from a standard normal distribution.
>
> In that case user will scroll in that scroll bar and histogram with
> different sample numbers will be drawn in the same plot.
>
> Is there any function/package in R to do that? Your help will be highly
> appreciated.
>
> Thanks,
> --
> View this message in context: http://n4.nabble.com/Interactive-plot-
> histogram-in-R-possible-tp1557984p1557984.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list