1.10 Naming objects
Names of objects can only contain letters, numbers, _ (underscore), or . (period), and must begin with a letter. It is good practice to give variables in a dataset and other objects descriptive names. There are various methods that are considered good practice for long names that have multiple words. You cannot include spaces in an object name, but any of the following can be used.
# "snake_case"
daily_cigarettes <- c(1,0,30)
# "CamelCase"
DailyCigarettes <- c(1,0,30)
Daily.Cigarettes <- c(1,0,30)
It is really a matter of preference but consistently sticking to one style will make your code easier to read and edit.
NOTE: R is case sensitive, so DailyCigarettes
and dailycigarettes
are considered to be different objects.