tagval: Extract value from tag-value formatted attributes

Description Usage Arguments Value Author(s) Examples

View source: R/feat.R

Description

Extract value from tag-value formatted attributes

Usage

1
tagval(x, tag)

Arguments

x

A vector of character strings in tag-val format (as described in the GFF 2 standard; ie, "tag1 val1a val1b; tag2 val2 ; ...", or in the GFF 3 format "tag1=val1a,val1b; tag2=val2; ..."), where vals are in quotes if they are strings.

tag

The tag whose values are to be extracted.

Value

If there is at most one value per tag for each element of x, a character vector of the same length as x will be returned, containing the value for each element, or NA if the tag does not exist for that element. If some elements have multiple values, then the return value will be a list with the same length as x, each element being a character vector containing the values for the corresponding element of x (or NA for no value).

Author(s)

Melissa J. Hubisz

Examples

1
2
3
4
5
6
7
8
9
tags <- c("tag1 \"val 1a\"; tag2 \"val 2a\" \"val2a.1\" 123; tag3 \"val3a\"",
          "tag1 \"val 1b\"; tag2 \"val 2b\"; tag4 \"val4b\"",
          "tag3 \"val3a\" 1; tag4 2;")
tagval(tags, "tag1")
tagval(tags, "tag2")
tagval(tags, "tag3")
tagval(tags, "tag4")
tagval(tags, "notag")
rm(tags)

rphast documentation built on May 1, 2019, 9:26 p.m.