What is the possible documentation available for R package? For example I try to understand sp
package.
In addition to help(sp)
, what are the other functions for searching through help and documentation?
Use ?
or, equivalently, help
.
?mean
help(mean) # same
For non-standard names use quotes or backquotes; see An Introduction to R: Getting help with functions and features:
For a feature specified by special characters, the argument must be enclosed in double or single quotes, making it a “character string”: This is also necessary for a few words with syntactic meaning including
if
,for
andfunction
."
?`if`
?"if" # same
help("if") # same
There are also help pages for datasets, general topics and some packages.
?iris
?Syntax
?lubridate
Use the example
function to see examples of how to use it.
example(paste)
example(`for`)
The demo
function gives longer demonstrations of how to use a function.
demo() # all demos in loaded pkgs
demo(package = .packages(all.available = TRUE)) # all demos
demo(plotmath)
demo(graphics)
Use ??
or, equivalently, help.search
.
??regression
help.search("regression")
Again, non-standard names and phrases need to be quoted.
??"logistic regression"
apropos
finds functions and variables in the current session-space (but not in installed but not-loaded packages) that match a regular expression.
apropos("z$") # all fns ending with "z"
rseek.org
is an R search engine with a Firefox plugin.
RSiteSearch
searches several sites directly from R.
findFn
in sos
wraps RSiteSearch
returning the results as a HTML table.
RSiteSearch("logistic regression")
library(sos)
findFn("logistic regression")
available.packages
tells you all the packages that are available in the repositories that you set via setRepositories
. installed.packages
tells you all the packages that you have installed in all the libraries specified in .libPaths
. library
(without any arguments) is similar, returning the names and tag-line of installed packages.
View(available.packages())
View(installed.packages())
library()
.libPaths()
Similarly, data
with no arguments tells you which datasets are available on your machine.
data()
search
tells you which packages have been loaded.
search()
packageDescription
shows you the contents of a package's DESCRIPTION
file. Likewise news
read the NEWS
file.
packageDescription("utils")
news(package = "ggplot2")
ls
lists the variables in an environment.
ls() # global environment
ls(all.names = TRUE) # including names beginning with '.'
ls("package:sp") # everything for the sp package
Most variables can be inspected using str
or summary
.
str(sleep)
summary(sleep)
ls.str
is like a combination of ls
and str
.
ls.str()
ls.str("package:grDevices")
lsf.str("package:grDevices") # only functions
For large variables (particularly data frames), the head
function is useful for displaying the first few rows.
head(sleep)
args
shows you the arguments for a function.
args(read.csv)
The Info page is a very comprehensive set of links to free R resources.
Many topics in R are documented via vignette
s, listed with browseVignettes
.
browseVignettes()
vignette("intro_sp", package = "sp")
By combining vignette
with edit
, you can get its code chunks in an editor.
edit(vignette("intro_sp",package="sp"))
This answer already gives you a very comprehensive list.
I would add that findFn("some search terms")
in package sos
is extremely helpful, if you only have an idea/keywords of what you are looking for and don't already have a package or function in mind.
And also the task views on CRAN: not really a search process but a great place to wander as you wonder.
This thread contains many good suggestions. Let me add one more.
For finding which packages are loaded, plus extra goodies, ?sessionInfo is quite nice.
help(package="<package-name>")
where of course <package-name>
is the name of the package you want help for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With