I think my mistake here is a misunderstanding about how functions operate within R but I do have some concerns that this might give me some strange results.
If I declare a parameter outside of a function, it overrides any parameters declared within the function call.
x<- 6
example<- function(...){
print(x^2)
}
example()
returns 36. I am ok with this.
However, if I run the function again and declare the variable, it gets ignored.
example(x =5)
still returns 36.
I can understand what is happening, but I don't really get why. Is using the ... bad practice in this case?
if my function is
example<- function(x){
print(x^2)
}
it works.