Jonas
Jonas

Reputation: 131

Extract value from RStudio manipulate package control

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.

Upvotes: 7

Views: 489

Answers (1)

Jonas
Jonas

Reputation: 131

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.

Upvotes: 5

Related Questions