Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

first.word

First Word in a String or Expression


Description

first.word finds the first word in an expression. A word is defined by unlisting the elements of the expression found by the S parser and then accepting any elements whose first character is either a letter or period. The principal intended use is for the automatic generation of temporary file names where it is important to exclude special characters from the file name. For Microsoft Windows, periods in names are deleted and only up to the first 8 characters of the word is returned.

Usage

first.word(x, i=1, expr=substitute(x))

Arguments

x

any scalar character string

i

word number, default value = 1. Used when the second or ith word is wanted. Currently only the i=1 case is implemented.

expr

any S object of mode expression.

Value

a character string

Author(s)

Frank E. Harrell, Jr.,
Department of Biostatistics,
Vanderbilt University,
fh@fharrell.com

Richard M. Heiberger,
Department of Statistics,
Temple University, Philadelphia, PA.
rmh@astro.ocis.temple.edu

Examples

first.word(expr=expression(y ~ x + log(w)))

Hmisc

Harrell Miscellaneous

v4.5-0
GPL (>= 2)
Authors
Frank E Harrell Jr <fh@fharrell.com>, with contributions from Charles Dupont and many others.
Initial release
2021-02-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.