Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6585747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:42:10+00:00 2026-05-25T16:42:10+00:00

In R, one very neat feature is that the source code of functions is

  • 0

In R, one very neat feature is that the source code of functions is accessible as objects in the workspace.

Thus, if I wanted to know the source code of, for example, grep() I can simply type grep into the console and read the code.

Similarly, I can read the documentation for grep by typing ?grep into the console.

Question: How can I get the source code for the documentation of a function? In other words, where do I find the .rd files?

I find studying the source of well-written code an excellent way of learning the idioms. Now I want to study how to write documentation for some very specific cases. I have not been able to find the documentation files for any of the base R functions in my R installation. Perhaps I have been looking in the wrong place.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:42:11+00:00Added an answer on May 25, 2026 at 4:42 pm

    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")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

jQuery has a very neat extend method, which merges 2 objects into one. On
There is one very nice feature in shell for example # asd > myfile.txt
I have one very general object that I want to map to a destination
I have a layout that is working, but it has one very annoying problem..
I don't know regular expression at all. Can anybody help me with one very
Notepad++ has a neat feature that combines search and highlighting. When you select a
we want to use git and one very important thing would be that if
I am using simple model which is a very neat piece of code but
I came across one very good library for parsing CUE files. But when I
I am modifying a wordpress theme completely, and have run into one very simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.