Skip to content
Prev 318583 / 398503 Next

using reserved words in R, and reuse variable names in different functions

On 13-03-01 8:35 PM, C W wrote:
Name them in ways that are meaningful to you.  R standard function names 
are famous for not following any naming pattern consistently.  Avoid 
using dots in the name unless you are defining methods (e.g. print.lm is 
the print method for lm objects).
Actually pi is not a function, but it is a variable.  If you write a 
package that exports a function or variable named pi, it would mask the 
standard one, and that could cause big problems for users.  If you use 
it internally, it will only mask the standard one in your code, and that 
may not matter to you.

pie is a function, but all it does is draw pie charts, so who cares if 
you mask it? :-).

Duncan Murdoch