Re: [R] Global variables

2015-07-28 Thread jpara3
Thanks to all!!! -- View this message in context: http://r.789695.n4.nabble.com/Global-variables-tp4710473p4710483.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see http

Re: [R] Global variables

2015-07-28 Thread Karim Mezhoud
normally that works, BUT <<- is BAD and not accepted in some repositories as Bioconductor. one<-function(){ a<-"variable passed" return(a) } x <- one() two<-function(x){ print(x) } On Tue, Jul 28, 2015 at 1:22 PM, jpara3 wrote: > Hi, I want to pass a variable value from one function to anoth

Re: [R] Global variables

2015-07-28 Thread Jeff Newmiller
Please don't. Function arguments are good... global variables are bad. one <- function(){ result <- list( a="variable passed" ) result } two <- function( v ){ print( v$a ) } x <- one() two( x ) --- Jeff Newmiller

Re: [R] Global variables

2015-07-28 Thread Michael Dewey
In line comments On 28/07/2015 13:22, jpara3 wrote: Hi, I want to pass a variable value from one function to another, but not as a function argument. For this propose I have put <<-, but it doesn´t work. My code: one<-function(){ a<<-"variable passed" } So you have to execute one() first?

[R] Global variables

2015-07-28 Thread jpara3
Hi, I want to pass a variable value from one function to another, but not as a function argument. For this propose I have put <<-, but it doesn´t work. My code: one<-function(){ a<<-"variable passed" } two<-function(){ print(a) } dos() If I execute dos(), then the error message is: Error in p

Re: [R] Global variables

2012-05-06 Thread Kenn Konstabel
On Fri, May 4, 2012 at 3:06 PM, Luis Goncalves wrote: > > > On May 2 2011, 3:02 pm, Kenn Konstabel wrote: >> On Mon, May 2, 2011 at 2:19 PM, abhagwat wrote: >> > Well, what would be really helpful is to restrict the scope of all >> > non-function variables, but keep a global for scope of all fun

Re: [R] Global variables

2011-05-02 Thread Kenn Konstabel
On Mon, May 2, 2011 at 2:19 PM, abhagwat wrote: > Well, what would be really helpful is to restrict the scope of all > non-function variables, but keep a global for scope of all function > variables. Then, you still have access to all loaded functions, but you > don't mix up variables. > > How wou

Re: [R] Global variables

2011-05-02 Thread Duncan Murdoch
On 02/05/2011 7:19 AM, abhagwat wrote: Well, what would be really helpful is to restrict the scope of all non-function variables, but keep a global for scope of all function variables. Then, you still have access to all loaded functions, but you don't mix up variables. How would one do that? Y

Re: [R] Global variables

2011-05-02 Thread abhagwat
Well, what would be really helpful is to restrict the scope of all non-function variables, but keep a global for scope of all function variables. Then, you still have access to all loaded functions, but you don't mix up variables. How would one do that? Adi > Is there a way I can prevent global

Re: [R] Global variables

2011-01-11 Thread Sebastien Bihorel
Thanks, I will have a look at it. Sebastien Michael Bedward wrote: Hi Sebastian, You might also find the proto package useful as a way of restricting the scope of variables. It provides a more intuitive (at least to me) way of packaging variables and functions up into environments that can be

Re: [R] Global variables

2011-01-10 Thread Michael Bedward
Hi Sebastian, You might also find the proto package useful as a way of restricting the scope of variables. It provides a more intuitive (at least to me) way of packaging variables and functions up into environments that can be related in a hierarchy. Michael On 10 January 2011 23:48, Sebastien B

Re: [R] Global variables

2011-01-10 Thread Sebastien Bihorel
Thank Gabor and Duncan, That will be helpful. Gabor Grothendieck wrote: > On Thu, Jan 6, 2011 at 4:59 PM, Duncan Murdoch > wrote: > >> On 06/01/2011 4:45 PM, Sebastien Bihorel wrote: >> >>> Dear R-users, >>> >>> Is there a way I can prevent global variables to be visible within my >>> f

Re: [R] Global variables

2011-01-06 Thread Gabor Grothendieck
On Thu, Jan 6, 2011 at 4:59 PM, Duncan Murdoch wrote: > On 06/01/2011 4:45 PM, Sebastien Bihorel wrote: >> >> Dear R-users, >> >> Is there a way I can prevent global variables to be visible within my >> functions? > > > Yes, but you probably shouldn't.  You would do it by setting the environment >

Re: [R] Global variables

2011-01-06 Thread Duncan Murdoch
On 06/01/2011 4:45 PM, Sebastien Bihorel wrote: Dear R-users, Is there a way I can prevent global variables to be visible within my functions? Yes, but you probably shouldn't. You would do it by setting the environment of the function to something that doesn't have the global environment a

[R] Global variables

2011-01-06 Thread Sebastien Bihorel
Dear R-users, Is there a way I can prevent global variables to be visible within my functions? Sebastien __ 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/post

Re: [R] global variables in a function

2009-12-10 Thread Gray Calhoun
Hi Keith, A more specific example of what you're looking for might be helpful--ie do you want to read global variables or set them? You probably want to look at environments and closures; ?"<<-" and ?assign are good starting points (the latter has an example of "Global Assignment within a function

Re: [R] global variables in a function

2009-12-10 Thread Gabor Grothendieck
I think you are looking for a macro facility. See defmacro in gtools which is based on Thomas Lumley's function of the same name whose article you can find in back issues of R News. On Thu, Dec 10, 2009 at 11:00 AM, Keith Jones wrote: > Y'all, > > I would like to have most of the variables in m

[R] global variables in a function

2009-12-10 Thread Keith Jones
Y'all, I would like to have most of the variables in my function to be global instead of local. I have not found any references that tell me now to do that. If I have missed a reference please excuse me and tell me what I have missed. Thanks, Keith Jones __