[R] Double-banger function names: preferences and suggestions

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Feb 26 11:21:54 CET 2007


hadley wickham wrote:
> What do you prefer/recommend for double-banger function names:
> 
>  1 scale.colour
>  2 scale_colour
>  3 scaleColour
> 
> 1 is more R-like, but conflicts with S3.  2 is a modern version of
> number 1, but not many packages use it.  Number 3 is more java-like.
> (I like number 2 best)

  Or you can be lisp-ish and use hyphens (or many other symbols) by quoting:

  > "scale-colour"=2
  > ls()
  [1] "scale-colour"

  but that requires further perversions:

  > get("scale-colour")
  [1] 2

  I like (3), aka camelCase - aka about a dozen other names: 
http://en.wikipedia.org/wiki/Camel_case - but that's mainly because its 
widely used in Python, and Python syntax is just marvellous. The more R 
syntax tends to Python syntax the better. Let's get rid of curly 
brackets and make whitespace significant...

  But I digress. As usual.

  ANytHiNg bUt sTUdLY cApS: http://en.wikipedia.org/wiki/StudlyCaps

Barry



More information about the R-help mailing list