http://support.rstudio.org/help/kb/advanced/interactive-plotting-with-manipulate
Basic Usage
The manipulate function accepts a plotting expression and a set of controls (e.g. slider, picker, or checkbox) which are used to dynamically change values within the expression. When a value is changed using its corresponding control the expression is automatically re-executed and the plot is redrawn.
For example, to create a plot that enables manipulation of a parameter using a slider control you could use syntax like this:
library(manipulate) manipulate(plot(1:x), x = slider(1, 100))
After this code is executed the plot is drawn using an initial value of 1 for x. A manipulator panel is also opened adjacent to the plot which contains a slider control used to change the value of x from 1 to 100.
Slider Control
The slider control enables manipulation of plot variables along a numeric range. For example:
manipulate( plot(cars, xlim=c(0,x.max)), x.max=slider(15,25))
Results in this plot and manipulator:
Slider controls also support custom labels and step increments.
No comments:
Post a Comment