Section 9 R Object Names
9.1 Naming Rules
A syntactically valid object name consists of letters, numbers, dots or underscore
The object name must start with a letter or dot.
The object name must not start with a number (not even the dot followed by a number).
The object name cannot be the following special reserved keywords:
break, else, FALSE, for, function, if, Inf, NA, NaN, next, NULL, repeat, return, TRUE, while
Object name cannot include some special symbols
- special symbols are
^, !, £, $, &, @, +, -, /, *
- some additional special symbols are
:,[, ], ~
- special symbols are
R is case-sensitive:
x
andX
are different objectsR will overwrite any previous information stored in an object
- it will not ask for permission.
Do not use object names already available in the global environment. It will overwrite the existing data contained in those objects.
Do not use the following letters for the object name:
c, t, T, F
Do not use the comment character
#
in the object name
9.2 Examples
Identify the CORRECT R object names from the following.
<- 5
myObj
<- 5
my.Obj
<- 5
my Obj
<- 5
_myObj
!myObj <- 5
<- 5
.myObj
<- 5
.my.Obj
<- 5
.3rd.my.Obj
-Obj <- 5
my
<- 5
my_Obj
<- 5
my_.Obj
<- 5
for.my.obj
<- 5
NULL.obj
TRUE <- 5
<- 5
T
<- 1
F
repeat <- 5
$my.Obj <- 5
<- 5
myNewObj
<- 5 c