User Tools

Site Tools


Sidebar

Translations of this page:

Back to BIS-Schools

Biodiversity data analysis with R

Lectures

Worksheets

Code

Excursus

en:learning:schools:s01:code-examples:ba-ce-12-02

C12-2 Missing values

Handling missing values is straight forward. Let’s start with a vector with one NA value at position 3. Please note that NA is not inside quotation marks since it is not a string but a special type of logical data type.

x <- c("A", "B", NA, "D")

To check, if the vector has one or more “not available” values, use the is.na function.

is.na(x)
## [1] FALSE FALSE  TRUE FALSE

It returns another vector which gives a TRUE/FALSE answer of the question for each value in the data structure.

If, for any reason, we want to assign the term “no value” to NAs, the scripting is quite simple and follows the standard logic.

x[is.na(x)] <- "no value"

en/learning/schools/s01/code-examples/ba-ce-12-02.txt · Last modified: 2015/09/22 16:22 (external edit)