Re: [R] Interactive plot

From: Greg Snow <Greg.Snow_at_imail.org>
Date: Mon, 30 Jun 2008 10:33:35 -0600

Here is a way that works for me using tkexamp in the TeachingDemos package (which uses tkrplot internally):

calc2 <- function(mat, vary1=0, vary2=0) calc(mat, c(vary1,vary2))

library(TeachingDemos)
tkexamp( calc2(mat, vary2=vary[2]),

        list(vary1=list('slider',from=0,to=4000, resolution=100, init=vary[1])))

# or

tkexamp( calc2(mat),

        list( vary1=list('slider', from=0, to=4000, resolution=100, init=vary[1]),
                vary2=list('slider', from=0, to=4000, resolution=100, init=vary[2])))

If you really want to use tkrplot directly, let me know, but it is a lot more code than above.

--
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 Ron Michael
> Sent: Saturday, June 28, 2008 11:00 PM
> To: r-help_at_stat.math.ethz.ch
> Subject: [R] Interactive plot
>
> Hi all,
>
> I have created following codes :
>
>
> mat = cbind(c(0.000059710430,0.000023057380),
> c(0.000023057380, 0.00005971089)) set.seed = 1000 vary =
> runif(dim(mat)[1], 2000, 3000) calc = function(mat, vary)
> {
> result = vector(length = (length(vary)+1))
> result[1] = sqrt(t(vary) %*% vary)
> for (i in 1 : length(vary))
> {
> result[(i+1)] = sum(vary)*sum(vary*mat[,i])
> }
> barplot(result)
> return(result)
> }
>
>
> Now I want to present the plot in some interactive manner. I
> want to put a slider in the plot where user move the slider
> for the 1st element of the vector "vary" and automatically
> this result will be reflected at the plot window. I already
> gone through some examples of "tkrplot" library, however
> unfortunately could not figure out how i can apply them in my problem.
>
> If anyone here explain me how to do that I would be grateful.
>
> Regards,
>
>
> Send instant messages to your online friends
> http://uk.messenger.yahoo.com
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
______________________________________________ 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.
Received on Mon 30 Jun 2008 - 16:40:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 30 Jun 2008 - 17:31:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive