Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract value from RStudio manipulate package control

Tags:

r

rstudio

Is there a way to extract current value from a slider control in manipulate package? For example:

library(manipulate)

xx <- seq(-pi, pi, pi/20)

manipulate(
  plot(xx, sin(par.a*xx)),
  par.a = slider(-3, 3, step=0.01, initial = 1))

After playing with the slider I would like to get the value of par.a for further calculations without having to look at the control and write it by hand each time.

like image 467
Jonas Avatar asked Oct 21 '22 00:10

Jonas


1 Answers

Figured it out myself.

It is possible to do with global variables

manipulate(
  {plot(xx, sin(par.a*xx))
  a <<- par.a},
  par.a = slider(-3, 3, step=0.01, initial = 1))

Maybe it will be of assistance to somebody.

like image 195
Jonas Avatar answered Oct 27 '22 09:10

Jonas