Learn R Programming

stringr (version 1.1.0)

str_replace_na: Turn NA into "NA"

Description

Turn NA into "NA"

Usage

str_replace_na(string, replacement = "NA")

Arguments

string
Input vector. Either a character vector, or something coercible to one.
replacement
Supply separate pattern and replacement strings to vectorise over the patterns. References of the form \1, \2 will be replaced with the contents of the respective matched group (created by ()) within the pattern.

For str_replace_all only, you can perform multiple patterns and replacements to each string, by passing a named character to pattern.

Examples

Run this code
str_replace_na(c(NA, "abc", "def"))

Run the code above in your browser using DataLab