qw: Perl-like function for quoting a list of words

View source: R/qw.R

qwR Documentation

Perl-like function for quoting a list of words

Description

qw stands for quote words. The function takes a string of words separated by whitespace characters. It returns a vector in which each element is a word. The point of the function is to speed the creation of vectors of words and to make for more readable code.

Usage

qw(x)

Arguments

x

A string. It may contain newline characters; x will be split by these characters just as it will be split by ordinary spaces. See the examples.

Details

This function is an R implementation of Perl's qw() operator. Sadly, the operator has no equivalent in Python.

Value

Character vector.

Author(s)

Florent Delmotte (“flodel”). See http://stackoverflow.com/questions/520810/.

See Also

https://perldoc.perl.org/5.30.0/perlop.html#Quote-Like-Operators.

Examples

 qw("You can type    text 
     with    line breaks if you
     wish")
 #  [1] "You"        "can"        "type"       "text"      
 #  [5] "here"       "with"       "linebreaks" "if"        
 #  [9] "you"        "wish"


jbullock35/Bullock documentation built on April 1, 2022, 6:21 p.m.