Learn R Programming

nuggets (version 1.4.0)

var_names: Extract variable names from predicates

Description

The function assumes that x is a vector of predicate names, i.e., a character vector with elements compatible with pattern <varname>=<value>. The function returns the <varname> part of these elements. If the string does not correspond to the pattern <varname>=<value>, i.e., if the equal sign (=) is missing in the string, the whole string is returned.

Usage

var_names(x)

Value

A <varname> part of predicate names in x.

Arguments

x

A character vector of predicate names.

Author

Michal Burda

Examples

Run this code
var_names(c("a=1", "a=2", "b=x", "b=y")) # returns c("a", "a", "b", "b")

Run the code above in your browser using DataLab