Modified version of tools:::.Rd_get_metadata()
that keeps whitespace and
returns character
instead of matrix
.
Arguments
- object
Rd
. R documentation, returned fromtools::Rd_db()
.- tag
character(1)
. Desired metadata type.These types are supported:
title
.description
.usage
.arguments
.value
.references
.seealso
.examples
.
Examples
db <- tools::Rd_db("base")
head(names(db))
#> [1] "Arithmetic.Rd" "AsIs.Rd" "Bessel.Rd" "CallExternal.Rd"
#> [5] "Colon.Rd" "Comparison.Rd"
rd <- db[["nrow.Rd"]]
print(rdTags(rd))
#> [1] "title" "name" "alias" "alias" "alias"
#> [6] "alias" "keyword" "description" "usage" "arguments"
#> [11] "value" "references" "seealso" "examples"
examples <- parseRd(rd, tag = "examples")
print(examples)
#> [1] "ma <- matrix(1:12, 3, 4)"
#> [2] "nrow(ma) # 3"
#> [3] "ncol(ma) # 4"
#> [4] ""
#> [5] "ncol(array(1:24, dim = 2:4)) # 3, the second dimension"
#> [6] "NCOL(1:12) # 1"
#> [7] "NROW(1:12) # 12, the length() of the vector"
#> [8] ""
#> [9] "## as.matrix() produces 1-column matrices from 0-length vectors,"
#> [10] "## and so does cbind() :"
#> [11] "dim(as.matrix(numeric())) # 0 1"
#> [12] "dim( cbind(numeric())) # ditto"
#> [13] "## consequently, NCOL(.) gives 1, too :"
#> [14] "NCOL(numeric()) # 1 and hence"
#> [15] "NCOL(NULL) # 1"