Table of Contents

R - Character type

About

A vector containing character values.

Example

> v = "My Name";
> class(v)
[1] "character"
> v <- c("My Name","Is","Nico")
> class(v)
[1] "character"

Management

Counting the number of occurrence

library(stringr)
str_count("/mt/path", "/")
[1] 2

Concatenate

Concatenate vectors after converting to character.

helloWorld <- paste0("Hello", "world", sep=" ")

where:

Escape \ Quotes

https://stat.ethz.ch/R-manual/R-devel/library/base/html/Quotes.html

Substring

substr(x, start, stop)
substring(text, first, last = 1000000L)
substr(x, start, stop) <- value
substring(text, first, last = 1000000L) <- value

Contain

test = "[nqSError: 46066]"
grepl("46066",test)
[1] TRUE