Learn R Programming

SparkR (version 3.1.2)

substr: substr

Description

An expression that returns a substring.

Usage

# S4 method for Column
substr(x, start, stop)

Arguments

x

a Column.

start

starting position. It should be 1-base.

stop

ending position.

See Also

Other column_func: alias(), between(), cast(), endsWith(), otherwise(), over(), startsWith()

Examples

Run this code
# NOT RUN {
df <- createDataFrame(list(list(a="abcdef")))
collect(select(df, substr(df$a, 1, 4))) # the result is `abcd`.
collect(select(df, substr(df$a, 2, 4))) # the result is `bcd`.
# }

Run the code above in your browser using DataLab