On 12/11/2008 7:59 AM, David Croll wrote:
>
> Hello dear R people!
>
>
> Several times it occurred to me that a function that uses a variable
name as a parameter would be helpful, but I did not find out how to
write such a function. I have experience in several programming
language, but I did no
David,
Having a function that changes global variables is very frowned on with few
exceptions. It falls into the category of things that you should never do
unless you fully understand why you should never do them (also see fortune(36)).
However, what you want to do may be more of a macro than
On 12/11/2008 7:59 AM, David Croll wrote:
Hello dear R people!
Several times it occurred to me that a function that uses a variable name as a
parameter would be helpful, but I did not find out how to write such a
function. I have experience in several programming language, but I did not come
David Croll wrote:
> Hello dear R people!
>
>
> Several times it occurred to me that a function that uses a variable name as
> a parameter would be helpful, but I did not find out how to write such a
> function. I have experience in several programming language, but I did not
> come across a hel
You're almost there:
a <- 12 # starting value
add <- function(variable,increment) {
variable + increment
}
add(a,25)
you shouldn't assign variable + increment to variable, unless you put a
return in your function:
add <- function(variable,increment) {
variable <- variable + incremen
5 matches
Mail list logo