How to access the help/documentation .rd source files in R?

£可爱£侵袭症+ 提交于 2019-11-27 22:12:16

It seems you can extract the Rd sources from an installed R. I'm using R-devel (2011-09-05 r56942).

Get the database of Rd for the base package.

library(tools)
db <- Rd_db("base")

Search for "grep.Rd" in the names of the Rd DB, for example:

grep("grep.Rd", names(db), value = TRUE)
[1] "d:/murdoch/recent/R64/src/library/base/man/agrep.Rd"
[2] "d:/murdoch/recent/R64/src/library/base/man/grep.Rd" 

Get just the Rd object for grep.

db[grep("/grep.Rd", names(db))]
$`d:/murdoch/recent/R64/src/library/base/man/grep.Rd`
\title{Pattern Matching and Replacement}
\name{grep}
\alias{grep}
\alias{grepl}
\alias{sub}
\alias{gsub}
\alias{regexpr}
\alias{gregexpr}
\alias{regexec}
\keyword{character}
\keyword{utilities}
\description{
\code{grep}, \code{grepl}, \code{regexpr} and \code{gregexpr} search
for matches to argument \code{pattern} within each element of a
character vector: they differ in the format of and amount of detail in
the results.

\code{sub} and \code{gsub} perform replacement of the first and all
matches respectively.
}\usage{
...
...

There are tools for getting the components from the Rd objects, so you can refine searching to keywords or name, see examples in ?Rd_db and try this.

lapply(db, tools:::.Rd_get_metadata, "name")
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!