parsePairs: Parse key-value pairs from a character string

Description Usage Arguments Details Value See Also Examples

View source: R/parseFuncs.R

Description

The function parses parameters in the form of KEY1=VAL1,KEY2=VAL2,KEY3=VAL3 into data.frame.

Usage

1
2
3
4
5
6
7
8
parsePairs(
  str,
  collapse = ",",
  sep = "=",
  colnames = c("key", "value"),
  trim = TRUE,
  ...
)

Arguments

str

Character string

collapse

Collapse character used in the string

sep

Seperator used in the string

colnames

Column names of the returned data.frame

trim

Logical, whether additional spaces should be trimmed

...

Further parameters passed to trim for fine-tuning of trimming

Details

If input string is NULL, the function returns NULL. This can be useful in case the parameter is optional and not specified.

Value

A data.frame containing keys and values

See Also

parseStrings

Examples

1
2
parsePairs("A=3,B=4,C=5", collapse=",", sep="=")
parsePairs("A:3|B:4|C:5", collapse="|", sep=":")

bedapub/ribiosArg documentation built on Nov. 4, 2021, 1:12 p.m.