Reserved words in R programming are a set of words that have special meaning and cannot be used as an identifier (variable name, function name etc.).
Here is a list of reserved words in the R's parser.
if | else | repeat | while | function |
for | in | next | break | TRUE |
FALSE | NULL | Inf | NaN | NA |
NA_integer_ | NA_real_ | NA_complex_ | NA_character_ | … |
This list can be viewed by typing help(reserved)
or ?reserved
at the R command prompt as follows.
Among these words, if
, else
, repeat
, while
, function
, for
, in
, next
and break
are used for conditions, loops and user defined functions.
They form the basic building blocks of programming in R.
TRUE
and FALSE
are the logical constants in R.
NULL
represents the absence of a value or an undefined value.
Inf
is for "Infinity", for example when 1 is divided by 0 whereas NaN
is for "Not a Number", for example when 0 is divided by 0.
NA
stands for "Not Available" and is used to represent missing values.
R is a case sensitive language. Which means that TRUE
and True
are not the same.
While the first one is a reserved word denoting a logical constant in R, the latter can be used as a variable name.
True <- 1
TRUE
True
Output
[1] TRUE [1] 1