Movatterモバイル変換


[0]ホーム

URL:


R

[Home]

Download

CRAN

R Project

R Foundation

Help With R

Documentation

Links

Getting Help with R

Helping Yourself

Before asking others for help, it’s generally a good idea for you totry to help yourself. R includes extensive facilities for accessingdocumentation and searching for help. There are also specialized searchengines for accessing information about R on the internet, and generalinternet search engines can also prove useful (see below).

R Help:help() and?

Thehelp() function and? help operator inR provide access to the documentation pages for R functions, data sets,and other objects, both for packages in the standard R distribution andfor contributed packages. To access documentation for the standardlm (linear model) function, for example, enter the commandhelp(lm) orhelp("lm"), or?lm or?"lm" (i.e., the quotes are optional).

To access help for a function in a package that’snotcurrently loaded, specify in addition the name of the package: Forexample, to obtain documentation for therlm() (robustlinear model) function in theMASS package,help(rlm, package="MASS").

Standard names in R consist of upper- and lower-case letters,numerals (0-9), underscores (_), and periods(.), and must begin with a letter or a period. To obtainhelp for an object with anon-standard name (such as the helpoperator?), the name must be quoted: for example,help('?') or?"?".

You may also use thehelp() function to accessinformation about a package in your library — for example,help(package="MASS") — which displays an index of availablehelp pages for the package along with some other information.

Help pages for functions usually include a section with executableexamples illustrating how the functions work. You can execute theseexamples in the current R session via theexample()command: e.g.,example(lm).

Vignettesand Code Demonstrations:browseVignettes(),vignette() anddemo()

Many packages includevignettes, which are discursivedocuments meant to illustrate and explain facilities in the package. Youcan discover vignettes by accessing the help page for a package, or viathebrowseVignettes() function: the commandbrowseVignettes() opens a list of vignettes fromall of your installed packages in your browser, whilebrowseVignettes(package=package-name) (e.g.,browseVignettes(package="survival")) shows the vignettes,if any, for a particular package.vignette() is employedsimilarly, but displays a list of vignettes in text form.

You can also use thevignette("vignette-name") commandto view a vignette (possibly specifying the name of the package in whichthe vignette resides, if the vignette name is not unique): for example,vignette("timedep") orvignette("timedep", package="survival") (which are, in thiscase, equivalent).

Vignettes may also be accessed from the CRAN page for the package(e.g. survival), if youwish to review the vignette for a package prior to installing and/orusing it.

Packages may also include extended code demonstrations (“demos”). Thecommanddemo() lists all demos for all packages in yourlibrary, whiledemo(package="package-name") (e.g.,demo(package="stats")) lists demos in a particular package.To run a demo, call thedemo() function with the quotedname of the demo (e.g.,demo("nlm")), specifying the nameof the package if the name of the demo isn’t unique (e.g.,demo("nlm", package="stats"), where, in this case, thepackage name need not be given explicitly).

Searching for Help Within R

Thehelp() function and? operator areuseful only if you already know the name of the function that you wishto use. There are also facilities in the standard R distribution fordiscovering functions and other objects. The following functions cast aprogressively wider net. Use the help system to obtain completedocumentation for these functions: for example,?apropos.

apropos()

Theapropos() function searches for objects, includingfunctions, directly accessible in the current R session that have namesthat include a specified character string. This may be a literal stringor aregular expression to be used for pattern-matching (see?"regular expression"). By default, string matching byapropos() is case-insensitive. For example,apropos("^glm") returns the names of all accessible objectsthat start with the (case-insensitive) characters"glm".

help.search() and??

Thehelp.search() function scans the documentation forpackages installed in your library. The (first) argument tohelp.search() is a character string or regular expression.For example,help.search("^glm") searches for help pages,vignettes, and code demos that have help “aliases,” “concepts,” ortitles that begin (case-insensitively) with the characters"glm". The?? operator is a synonym forhelp.search(): for example,??"^glm".

RSiteSearch()

RSiteSearch() uses aninternet search engine (also seebelow) to search for informationin function help pages and vignettes for all CRAN packages, and in CRANtask views (describedbelow). Unlike theapropos() andhelp.search() functions,RSiteSearch() requires an active internet connection anddoesn’t employ regular expressions. Braces may be used to specifymulti-word terms; otherwise matches for individual words are included.For example,RSiteSearch("{generalized linear model}")returns information about R functions, vignettes, and CRAN task viewsrelated to the term"generalized linear model" withoutmatching the individual words"generalized","linear", or"model".

findfn() and??? in thesos package, which isnot part of the standardR distribution but is available on CRAN, provide an alternativeinterface toRSiteSearch().

help.start()

help.start() starts and displays a hypertext basedversion of R’s online documentation in your default browser thatprovides links to locally installed versions of the R manuals, a listingof your currently installed packages and other documentationresources.

R Help on the Internet

There are internet search sites that are specialized for R searches,includingsearch.r-project.org (which isthe site used byRSiteSearch) andRseek.org.

It is also possible to use a general search site likeGoogle, by qualifying the search with“R” or the name of an R package (or both). It can be particularlyhelpful to paste an error message into a search engine to find outwhether others have solved a problem that you encountered.

CRAN Task Views

CRAN Task Views are documents that summarize R resources on CRAN inparticular areas of application, helping your to navigate the maze ofthousands of CRAN packages. Alist of available TaskViews may be found on CRAN.

R FAQs (Frequently AskedQuestions)

There are three primary FAQ listings which are periodically updatedto reflect very commonly asked questions by R users. There is aMain R FAQ, aWindowsspecific R FAQ and aMac OS (OSX) specific R FAQ.

Asking for Help

If you find that you can’t answer a question or solve a problemyourself, you can ask others for help, either locally (if you knowsomeone who is knowledgeable about R) or on the internet. In order toask a question effectively, it helps to phrase the question clearly,and, if you’re trying to solve a problem, to include a small,self-contained, reproducible example of the problem that others canexecute. For information on how to ask questions, see, e.g., the Rmailing listposting guide,and the document abouthowto create reproducible examples for R on Stack Overflow.

Stack Overflow

Stack Overflow is a wellorganized and formatted site for help and discussions about programming.It has excellent searchability. Topics are tagged, and“r” is a very popular tagon the site with almost 150,000 questions (as of summer 2016). To godirectly to R-related topics, visithttp://stackoverflow.com/questions/tagged/r.For an example both of the value of the site’s organization andinformation that is very useful to R users, see“Howto make a great R reproducible example?”, which is also mentionedabove.

R Email Lists

The R Project maintains a number of subscription-basedemail lists for posingand answering questions about R, including the generalR-help emaillist, theR-devel listfor R code development, andR-package-devellist for developers of CRAN packages; lists for announcements aboutR andR packages;and a variety of more specialized lists. Before posing a question on oneof these lists, please read theR mailing listinstructions and thepostingguide.

© The R Foundation. For queries about this web site, please contact; for queries about R itself, please consult theGetting Help section.

[8]ページ先頭

©2009-2025 Movatter.jp