10 ms·
> One quirk that got me the last time I touched R was that functions and variables live in different namespaces, so you could assign 4 to foo and then call it.
by s1t5 6y ago
> One quirk that got me the last time I touched R was that functions and variables live in different namespaces, so you could assign 4 to foo and then call it.
Either I'm greatly misunderstanding or this is just plain wrong - assigning something to the same name as an existing function will just overwrite the function.
- notafraudster 6y agoYou're correct provided the overwrite is occurring in the same namespace (e.g. the local environment). He is correct for the wrong reason if you try to alias something from another environment. For example, the following R code may initial seem weird: my_vec <- c(1, 2, 3) c <- 4 print(c) my_vec2 <- c(5, 6, 7) But as I describe in my top level comment, it has nothing to do with variables versus functions, just how namespaces work.