I will try this. thank you.
2012/11/23 Milan Bouchet-Valat <nalimi...@club.fr> > Le vendredi 23 novembre 2012 à 03:17 +0100, vincent guyader a écrit : > > Hi everyone, > > > > I made some tests with Rcmdr, to add a function with default parameters : > > > > For example (very simple): > > > > myfunction<-function(var="314"){ > > print("hello") > > print(var) > > } > > > > if I run myfunction() directly i see : > > > > > myfunction() > > [1] "hello" > > [1] "314" > > > > it's ok. > > > > But if i edit de Rcmdr-menu.txt (in > > C:\Users\myname\Documents\R\win-library\2.15\Rcmdr\etc) > > and add : > > > > menu MyMenu topMenu > > "" "" > > "" "" > > item topMenu cascade > > "MyTest" MyMenu "" "" > > item MyMenu command "Test" > > myfunction "" "" > > > > and I put myfonction into a file Rcmdr-test.R in the same folder > > > > I have a new button with a cascade menu, and myfunction is corectly > > sourced.. but : > > > > > > that's what append : > > > > > library(Rcmdr) > > Loading required package: tcltk > > Loading Tcl/Tk interface ... done > > Loading required package: car > > Loading required package: MASS > > Loading required package: nnet > > Sourced: Rcmdr-test.r > > > > > > Rcmdr Version 1.9-2 > > > > If i use the Menu : > > > > [1] "hello" > > [1] "%var" > > > > ->there are %var instead off 314. > > > myfunction > > function(var="314"){ > > print("hello") > > print(var) > > } > > > > I think that I made a mistake but I dont know were. How can I use Rcmdr > > menu AND a default parameter ? > > > > Can you help me? > I'm not sure how it's supposed to work in Rcmdr, but a very simple > workaround is to call from the menus a custom function defined like > this: > doMyfunction <- function() myfunction() > > Another solution is to add "..." before "var" in the arguments list of > your function. That way, the first argument passed by Rcmdr will not > incorrectly be matched to "var". > myfunction <- function(..., var="314"){ > print("hello") > print(var) > } > > > My two cents > [[alternative HTML version deleted]]
______________________________________________ R-help@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.