rev_sentence: Reverse the order of words in a string

View source: R/string_tools.R

rev_sentenceR Documentation

Reverse the order of words in a string

Description

Reverse the order of words in a string

Usage

rev_sentence(vec, split = " |_", join = " ")

Arguments

vec

(Character) The vector to reverse.

split

(Character) A regular expression that determines where vec will be split into separate words. By default, splits at spaces and underscores.

join

(Character) A string that will be inserted between the words.

Value

A character vector that is the same length as vec.

Authors

Examples

vec <- c("Lorem ipsum dolor",
         "sit amet, consectetur",
         "adipiscing elit, sed",
         "do eiusmod tempor",
         "incididunt ut labore",
         "et dolore magna",
         "aliqua.")

rev_sentence(vec)

## [1] "dolor ipsum Lorem"  "consectetur amet, sit"  "sed elit, adipiscing"  
## [4] "tempor eiusmod do"  "labore ut incididunt"  "magna dolore et"  "aliqua."   


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.