How to Distinguish Data Types in R
How to Successfully Follow Naming Conventions in R
How to Predict New Data Values with R

How to Select Naming Styles in R

If you have experience in programming, you’ve probably heard of camel case, before. It’s a way of giving longer names to objects and functions. You capitalize every first letter of a word that is part of the name to improve the readability. So, you can have a veryLongVariableName and still be able to read it.

Contrary to many other languages, R doesn’t use the dot (.) as an operator, so the dot can be used in names for objects as well. This style is called dotted style, where you write everything in lowercase and separate words or terms in a name with a dot.

In fact, in R, many function names use dotted style. You’ve met a function like this earlier. print.default(). Some package authors also use an underscore instead of a dot.

print.default() is the default method for the print() function. Information on the arguments is given on the Help page for print.default().

You’re not obligated to use dotted style; you can use whatever style you want. R uses dotted style for many base functions and objects, but because some parts of the internal mechanisms of R rely on that dot, you’re safer to use camel case for functions. Whenever you see a dot, though, you don’t have to wonder what it does — it’s just part of the name.

The whole naming issue reveals one of the downsides of using open-source software: It’s written by very intelligent and unselfish people with very strong opinions, so the naming of functions in R is far from standardized.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
How to Create a Bar Chart Using ggplot2 in R
How to Use Dimensions to Extract Values from an Array in R
How to Substitute Text in R
How to Create Vectors in R
How to Use Internal Functions in R
Advertisement

Inside Dummies.com