Reserved words

    R Reserved Words

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.)this 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.

Reserved words in R
ifelserepeatwhilefunction
forinnextbreakTRUE
FALSENULLInfNaNNA
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.

> ?reserved

Among these words, ifelserepeatwhilefunctionforinnext 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 mean 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 a variable name.

> TRUE <- 1
Error in TRUE <- 1 : invalid (do_set) left-hand side to assignment

> True <- 1

> TRUE
[1] TRUE

> True
[1] 1

Comments

Popular posts from this blog

vocab

📚Gds-Tech 📚 EMS

spreadsheet in excel