[R] loop variable names as function arguments

P Wilson P.Wilson at sheffield.ac.uk
Wed Jan 5 12:36:06 CET 2011


Dear all, is there a way to loop the rp.doublebutton function in the rpanel
package? The difficulty I'm having lies with the variable name argument.

library(rpanel)
if (interactive()) {
   draw <- function(panel) {
     plot(unlist(panel$V),ylim=0:1)
     panel
     }
   panel <- rp.control(V=as.list(rep(.5,3)))
   rp.doublebutton(panel, var = V[[1]], step = 0.05, action = draw, range = c(0,
1))
   rp.doublebutton(panel, var = V[[2]], step = 0.05, action = draw, range = c(0,
1))
   rp.doublebutton(panel, var = V[[3]], step = 0.05, action = draw, range = c(0,
1))
   }

Regards,
Philip



More information about the R-help mailing list