Appendix: R Reference - R in a Nutshell
Pages: 1, 2, 3, 4, 5
stats
This package contains functions to perform a wide varietyof statistical analyses.
Functions
stats4
This package contains statistical functions using S4methods and classes.
Functions
| Function | Description |
|---|---|
| AIC | Calculates the Akaike information criterion for one orseveral fitted model objects for which a log-likelihood valuecan be obtained. |
| BIC | Calculates the Bayesian information criterion (BIC), also known as Schwarz's Bayesian criterion (SBC), for one orseveral fitted model objects for which a log-likelihood valuecan be obtained, according to the formula −2 ∗ log-likelihood+ npar ∗log(nobs), wherenpar representsthe number of parameters andnobs the number ofobservations in the fitted model. |
| coef | Extracts model coefficients from objects returned bymodeling functions. |
| confint | Computes confidence intervals for one or moreparameters in a fitted model. |
| logLik | Extracts the log-likelihood from a modelobject. |
| mle | Estimates parameters by the method of maximumlikelihood. |
| plot | Generic function for plotting an R object. |
| profile | Investigates behavior of objective function near thesolution represented by fitted. |
| summary | Generic function used to produce result summaries ofthe results of various model-fitting functions. |
| update | Updates and (by default) refits a model. |
| vcov | Returns the variance-covariance matrix of the mainparameters of a fitted model object. |
survival
This package contains functions for survivalanalysis.
Functions
Data Sets
tcltk
The package contains interface and language bindings toTcl/Tk GUI elements. Please see the online help for more details.
tools
This package provides tools for developingpackages.
Functions
| Function | Description |
|---|---|
| Rd2HTML | This (experimental) function converts from an R helppage to an HTML document. |
| Rd2ex | This (experimental) function converts from an R helppage to the format used by example. |
| Rd2latex | This (experimental) function converts from an R helppage to a LaTeX document. |
| Rd2txt | This (experimental) function converts from an R helppage to a text document. |
| Rd_db | Builds a simple database of all R documentation (Rd)sources in a package, as a list of character vectors with thelines of the Rd files in the package. |
| Rdiff | Given two R output files, computes differences, ignoring headers, footers, and some encodingdifferences. |
| Rdindex | Prints a two-column index table with names and titlesfrom given R documentation files to a given output file orconnection. The titles are nicely formatted between two columnpositions (typically 25 and 72, respectively). |
| buildVignettes | Runs Sweave andtexi2dvi on all vignettesof a package. |
| checkDocFiles | Checks, for all Rd files in a package, whether allarguments shown in the usage sections of the Rd file aredocumented in its arguments section. |
| checkDocStyle | Investigates how (S3) methods are shown in the usagesof the Rd files in a package. |
| checkFF | Performs checks on calls to compiled code from Rcode. |
| checkMD5sums | Checks the files against a file "MD5". |
| checkNEWS | Reads R's NEWS file or a similarly formatted one. Thisis an experimental feature, new in R 2.4.0, and may change inseveral ways. |
| checkRd | These experimental functions take the output of theparse_Rd function and checkit or produce a help page from it. Their interfaces (andexistence!) are subject to change. |
| checkReplaceFuns | Checks whether replacement functions or S3/S4replacement methods in the package R code have their finalargument named value. |
| checkS3methods | Checks whether all S3 methods defined in the package Rcode have all arguments of the corresponding generic, withpositional arguments of the generics in the same positions forthe method. |
| checkTnF | Checks the specified R package or code file foroccurrences of T orF and gathers theexpressions containing these. |
| checkVignettes | Checks all Sweavefiles of a package by running Sweave and/or Stangle on them. |
| codoc | Compares names and optionally also correspondingpositions and default values of the arguments offunctions. |
| codocClasses | Finds inconsistencies between actual and documented"structure" of R objects in a package. codoc compares names and optionallyalso corresponding positions and default values of thearguments of functions. codocClasses and codocData compare slot names of S4classes and variable names of data sets, respectively. |
| codocData | Compares slot names of S4 classes. |
| delimMatch | Matches delimited substrings in a character vector, with proper nesting. |
| dependsOnPkgs | Finds "reverse" dependencies of packages, i.e., thosepackages that depend on this one and (optionally) so onrecursively. |
| encoded_text_to_latex | Translates non-ASCII characters in text to LaTeX escapesequences. |
| file_path_as_absolute | Turns a possibly relative file path absolute, performing tilde expansion, if necessary. |
| file_path_sans_ext | Returns the file paths without extension. |
| findHTMLlinks | Finds HTML links in an R help file. |
| getDepList | Given a dependency matrix, creates a DependsList object for that package, which will include the dependencies for that matrix, whichones are installed, which unresolved dependencies were foundonline, which unresolved dependencies were not found online, and any R dependencies. |
| installFoundDepends | Takes the Foundelement of a pkgDependsListobject and attempts to install all of the listed packages fromthe specified repositories. |
| list_files_with_exts | Returns the paths or names of the files in directorydir with extensions matching one of the elements ofexts. |
| list_files_with_type | Returns the paths of the files in dir of the given"type, " as determined by the extensions recognized byR. |
| md5sum | Computes the 32-byte MD5 checksums of one or morefiles. |
| package.dependencies | Parses and checks the dependencies of a package againstthe currently installed version of R (and otherpackages). |
| parse_Rd | Reads an Rd file and parses it, for processing by otherfunctions. It is experimental. |
| pkgDepends | Convenience function that wraps getDepList and takes asinput a package name. |
| pkgVignettes | Runs Sweave andtexi2dvi on all vignettesof a package. |
| read.00Index | Reads item/description information from 00Index-stylefiles. |
| readNEWS | Read R's NEWS file or a similarly formatted one. Thisis an experimental feature, new in R 2.4.0, and may change inseveral ways. |
| showNonASCII | Prints elements of a character vector that containnon-ASCII bytes, printing such bytes as an escape like<fc>. |
| testInstalledBasic | Allows an installed package to be tested by running thebasic tests. |
| testInstalledPackage | Allows an installed package to be tested. |
| testInstalledPackages | Allows all base and recommended packages to betested. |
| texi2dvi | Runs latex andbibtex until allcross-references are resolved and creates either a deviceindependent (DVI) or a PDF file. |
| undoc | Finds the objects in a package that are undocumented, in the sense that they are visible to the user (or dataobjects or S4 classes provided by the package), but nodocumentation entry exists. |
| vignetteDepends | Given a vignette name, creates a DependsList objectthat reports information about the packages the vignettedepends on. |
| write_PACKAGES | Generates PACKAGESand PACKAGES.gz files for arepository of source or Mac/Windows binary packages. |
| xgettext, xgettext2pot, xngettext | For each file in the R directory (includingsystem-specific subdirectories) of a package, extract theunique arguments passed to stop, warning, message, gettext, and gettextf, or to ngettext. |
Data Sets
utils
This package contains a variety of utility functions forR, including package management, file reading and writing, andediting.
Functions
| Function | Description |
|---|---|
| ? | Documentation on a topic. |
| RShowDoc | Utility function to find and display Rdocumentation. |
| RSiteSearch | Searches for keywords or phrases in the R-help mailinglist archives, help pages, vignettes, or task views, using thesearch engine at http://search.r-project.org, and displays theresults in a web browser. |
| Rprof | Enables or disables profiling of the execution of Rexpressions. |
| Rprofmem | Enables or disables reporting of memory allocation inR. |
| Rtangle | A driver for Stanglethat extracts R code chunks. |
| RtangleSetup | A driver for Stanglethat extracts R code chunks. |
| RtangleWritedoc | These functions are handy for writing Sweave driversand currently not documented. Look at the source code of theSweave Latex driver (in this package) or the HTML driver (inthe R2HTML package from CRAN) to see how they can beused. |
| RweaveChunkPrefix | These functions are handy for writing Sweave driversand currently not documented. Look at the source code of theSweave Latex driver (in this package) or the HTML driver (inthe R2HTML package from CRAN) to see how they can beused. |
| RweaveEvalWithOpt | These functions are handy for writing Sweave driversand currently not documented. Look at the source code of theSweave Latex driver (in this package) or the HTML driver (inthe R2HTML package from CRAN) to see how they can beused. |
| RweaveLatex | A driver for Sweavethat translates R code chunks in LaTeX files. |
| RweaveLatexFinish | These functions are handy for writing Sweave driversand currently not documented. Look at the source code of theSweave Latex driver (in this package) or the HTML driver (inthe R2HTML package from CRAN) to see how they can beused. |
| RweaveLatexOptions | These functions are handy for writing Sweave driversand currently not documented. Look at the source code of theSweave Latex driver (in this package) or the HTML driver (inthe R2HTML package from CRAN) to see how they can beused. |
| RweaveLatexSetup | A driver for Sweavethat translates R code chunks in LaTeX files. |
| RweaveLatexWritedoc | These functions are handy for writing Sweave driversand currently not documented. Look at the source code of theSweave Latex driver (in this package) or the HTML driver (inthe R2HTML package from CRAN) to see how they can beused. |
| RweaveTryStop | These functions are handy for writing Sweave driversand currently not documented. Look at the source code of theSweave Latex driver (in this package) or the HTML driver (inthe R2HTML package from CRAN) to see how they can beused. |
| Stangle | A frontend to Sweaveusing a simple driver by default, which discards thedocumentation and concatenates all code chunks the current Sengine understands. |
| Sweave | Sweave provides aflexible framework for mixing text and S code for automaticreport generation. The basic idea is to replace the S codewith its output, such that the final document only containsthe text and the output of the statistical analysis. |
| SweaveSyntConv | This function converts the syntax of files in Sweave format to another Sweavesyntax definition. |
| URLdecode | Function to decode characters in URLs. |
| URLencode | Function to encode characters in URLs. |
| View | Invokes a spreadsheet-style data viewer on amatrix-like R object. |
| alarm | Gives an audible or visual signal to the user. |
| apropos | apropos() returns acharacter vector giving the names of all objects in the searchlist matching a specified value. |
| argsAnywhere | Returns the arguments for all functions with a namematching its argument, whether visible on the search path, registered as an S3 method, or in a namespace but notexported. |
| as.person | A class and utility method for holding informationabout persons such as name and email address. |
| as.personList | A class and utility method for holding informationabout persons such as name and email address. |
| as.relistable | relist() is an S3generic function with a few methods in order to allow easyinversion of unlist(obj)when that is used with an object of (S3) class "relistable". |
| as.roman | Manipulates integers as roman numerals. |
| assignInNamespace | Utility function to access and replace the nonexportedfunctions in a namespace, for use in developing packages withnamespaces. |
| available.packages | Used to automatically compare the version numbers ofinstalled packages with the newest available version on therepositories and update outdated packages on the fly. |
| browseEnv | Opens a browser with list of objects currently in thesys.frame()environment. |
| browseURL | Loads a given URL into a web browser. |
| browseVignettes | Lists available vignettes in an HTML browser with linksto PDF, LaTeX/noweb source, and (tangled) R code (ifavailable). |
| bug.report | Invokes an editor to write a bug report and optionallymail it to the automated r-bugs repository atr-bugs@r-project.org. Some standardinformation on the current version and configuration of R areincluded automatically. |
| capture.output | Evaluates its arguments with the output being returnedas a character string or sent to a file. Related to sink in the same way that with is related to attach. |
| checkCRAN | Functions helping to maintain CRAN, some of which mayalso be useful to administrators of other repositorynetworks. |
| chooseCRANmirror | Interacts with the user to choose a CRANmirror. |
| citEntry | Creates "citation" objects, which are modeled afterBibTeX entries. |
| citFooter | Creates a footer in a CITATION file. |
| citHeader | Creates a header in a CITATION file. |
| citation | Shows how to cite R and R packages inpublications. |
| close.socket | Closes the socket and frees the space in the filedescriptor table. The port may not be freedimmediately. |
| combn | Generates all combinations of the elements of x taken m at a time. If x is a positive integer, returns allcombinations of the elements of seq(x) taken m at a time. If argument FUN is not NULL, applies a function given bythe argument to each point. If simplify is FALSE, returns alist; otherwise, returns an array, typically a matrix. ... are passed unchanged to theFUN function, ifspecified. |
| compareVersion | Compares two package version numbers to see which islater. |
| contrib.url | Used to automatically compare the version numbers ofinstalled packages with the newest available version on therepositories and update outdated packages on the fly. |
| count.fields | Counts the number of fields, as separated by sep, in each of the lines offile read. |
| data | Loads specified data sets or lists the available datasets. |
| data.entry, dataentry, de, de.ncols, de.restore, de.setup | Spreadsheet-like editors for entering or editingdata. |
| debugger | Function to dump the evaluation environments (frames)and to examine dumpedframes. |
| demo | User-friendly interface for running some demonstrationR scripts. demo() gives thelist of available topics. |
| download.file | Used to download a file from the Internet. |
| download.packages | Used to automatically compare the version numbers ofinstalled packages with the newest available version on therepositories and update outdated packages on the fly. |
| dump.frames | Function to dump the evaluation environments (frames)and to examine dumpedframes. |
| edit | Invokes an editor on an R object. |
| emacs | Invokes the text editor emacs on an R object. |
| example | Runs all the R code from theExamples part of R's online help. |
| file.edit | Edits one or more files in a text editor. |
| file_test | Utility for shell-style file tests. |
| find | Returns a character vector giving the names of allobjects in the search list matching a given value. |
| fix | Invokes edit onx and assigns the new(edited) version of x inthe user's workspace. |
| fixInNamespace | Utility function to access and replace the nonexportedfunctions in a namespace, for use in developing packages withnamespaces. |
| flush.console | On the Mac OS X and Windows GUIs, ensures that thedisplay of output in the console is current, even if outputbuffering is on. (This does nothing except on console-basedversions of R.) |
| formatOL, formatUL | Format unordered (itemize) and ordered (enumerate)lists. |
| getAnywhere | Locates and returns all objects with a name matchingits argument, whether visible on the search path, registeredas an S3 method, or in a namespace but not exported. |
| getCRANmirrors | Interacts with the user to choose a CRANmirror. |
| getFromNamespace | Utility function to access and replace the nonexportedfunctions in a namespace, for use in developing packages withnamespaces. |
| getS3method | Gets a method for an S3 generic, possibly from anamespace. |
| getTxtProgressBar | Text progress bar in the R console. |
| glob2rx | Changes wildcard (akaglobbing) patterns into the correspondingregular expressions (regexp). |
| head | Returns the first or last parts of a vector, matrix, table, data frame, or function. Since head() and tail() are generic functions, theymay also have been extended to other classes. |
| help | The primary interface to R's help system. |
| help.request | Prompts users to check they have done all that isexpected of them before sending a post to the R-help mailinglist, provides a template for the post with sessioninformation included, and optionally sends the email (on Unixsystems). |
| help.search | Allows for searching the help system for documentationmatching a given character string in the (file) name, alias, title, concept, or keyword entries (or any combinationthereof), using either fuzzy matching or regular expressionmatching. Names and titles of the matched help entries aredisplayed nicely formatted. |
| help.start | Starts the hypertext (currently HTML) version of R'sonline documentation. |
| history | Loads or saves or displays the commandshistory. |
| index.search | Used to search the indexes for help files, possiblyunder aliases. |
| install.packages | Used to automatically compare version numbers ofinstalled packages with the newest available version on therepositories and update outdated packages on the fly. |
| installed.packages | Finds (or retrieves) details of all packages installedin the specified libraries. |
| is.relistable | relist() is an S3generic function with a few methods in order to allow easyinversion of unlist(obj)when that is used with an object of (S3) class "relistable". |
| limitedLabels | Allows the user to browse directly on any of thecurrently active function calls and is suitable as an erroroption. The expression options(error=recover) will makethis the error option. |
| loadhistory | Loads or saves or displays the commandshistory. |
| localeToCharset | Aims to find a suitable coding for the locale named, bydefault the current locale, and if it is a UTF-8 locale, asuitable single-byte encoding. |
| ls.str, lsf.str | ls.str and lsf.str are variations of ls applying str() to each matched name. |
| make.packages.html | Updates HTML documentation files. |
| make.socket | With server = FALSE, attempts to open a client socket to the specified port andhost. With server = TRUE, listens on the specified port for a connection and thenreturns a server socket. It is a good idea to use on.exit to ensure that a socket isclosed, as you only get 64 of them. |
| makeRweaveLatexCodeRunner | These functions are handy for writing Sweave driversand currently not documented. Look at the source code of theSweave Latex driver (in this package) or the HTML driver (inthe R2HTML package from CRAN) to see how they can beused. |
| memory.limit | Gets or sets the memory limit on Microsoft Windowsplatforms. |
| memory.size | Checks the current memory usage on Microsoft Windowsplatforms. |
| menu | Presents the user with a menu of choices labeled from 1to the number of choices. To exit without choosing an item, select 0. |
| methods | Lists all available methods for an S3 generic functionor all methods for a class. |
| mirror2html | Functions helping to maintain CRAN, some of which mayalso be useful to administrators of other repositorynetworks. |
| modifyList | Modifies a possibly nested list recursively by changinga subset of elements at each level to match a secondlist. |
| new.packages | Used to automatically compare the version numbers ofinstalled packages with the newest available version on therepositories and update outdated packages on the fly. |
| normalizePath | Converts file paths to canonical form for the platform, to display them in a user-understandable form. |
| nsl | Interface to gethostbyname. |
| object.size | Provides an estimate of the memory that is being usedto store an R object. |
| old.packages | Used to automatically compare the version numbers ofinstalled packages with the newest available version on therepositories and update outdated packages on the fly. |
| package.skeleton | Automates some of the setup for a new source package.It creates directories; saves functions, data, and R codefiles to appropriate places; and creates skeleton help filesand a Read-and-delete-mefile describing further steps in packaging. |
| packageDescription | Parses and returns the DESCRIPTION file of apackage. |
| packageStatus | Summarizes information about installed packages andpackages available at various repositories, and automaticallyupgrades outdated packages. |
| page | Displays a representation of the object named byx in a pager via file.show. |
| person | Creates a "person" object. |
| personList | Creates a "personList" object. |
| pico | Invokes a text editor on an R object. |
| prompt | Facilitates the construction of files documenting Robjects. |
| promptData | Generates a shell of documentation for a dataset. |
| promptPackage | Generates a shell of documentation for an installed orsource package. |
| read.DIF | Reads a file in Data Interchange Format (DIF) andcreates a data frame from it. DIF is a format for datamatrices such as single spreadsheets. |
| read.csv, read.csv2, read.delim, read.delim2 | Read a file in table format and create a data framefrom it, with cases corresponding to lines and variables tofields in the file. |
| read.fortran | Reads fixed-format data files using FORTRAN-styleformat specifications. |
| read.fwf | Reads a table of fixed-width-formatted data into adata.frame. |
| read.socket | read.socket reads astring from the specified socket; write.socket writes to the specifiedsocket. There is very little error checking done byeither. |
| read.table | Reads a file in table format and creates a data framefrom it, with cases corresponding to lines and variables tofields in the file. |
| readCitationFile | The CITATION fileof R packages contains an annotated list of references thatshould be used for citing the packages. |
| recover | Allows the user to browse directly on any of thecurrently active function calls and is suitable as an erroroption. The expression options(error=recover) will makethis the error option. |
| relist | relist() is an S3generic function with a few methods in order to allow easyinversion of unlist(obj)when that is used with an object of (S3) class "relistable". |
| remove.packages | Removes installed packages/bundles and updates indexinformation as necessary. |
| rtags | Provides etags-like indexing capabilities for R code, using R's own parser. |
| savehistory | Loads or saves or displays the commandshistory. |
| select.list | Selects item(s) from a character vector. |
| sessionInfo | Prints version information about R and attached orloaded packages. |
| setRepositories | Interacts with the user to choose the packagerepositories to be used. |
| setTxtProgressBar | Text progress bar in the R console. |
| stack | Stacking vectors concatenates multiple vectors into asingle vector along with a factor indicating where eachobservation originated; unstacking reverses this. |
| str | Compactly displays the internal structure of an Robject; the idea is to give reasonable output forany R object. |
| strOptions | strOptions() is aconvenience function for setting options(str = .). |
| summaryRprof | Summarizes the output of the Rprof function to show the amount oftime used by different R functions. |
| tail | Returns the first or last parts of a vector, matrix, table, data frame, or function. Since head() and tail() are generic functions, theymay also have been extended to other classes. |
| timestamp | Loads or saves or displays the commandshistory. |
| toBibtex | Converts R objects to character vectors with BibTeXmarkup. |
| toLatex | Converts R objects to character vectors with LaTeXmarkup. |
| txtProgressBar | Text progress bar in the R console. |
| type.convert | Converts a character vector to logical, integer, numeric, complex, or factor, as appropriate. |
| unstack | Stacking vectors concatenates multiple vectors into asingle vector along with a factor indicating where eachobservation originated; unstacking reverses this. |
| unzip | Extracts files from or lists a zip archive. |
| update.packageStatus | Summarizes information about installed packages andpackages available at various repositories and automaticallyupgrades outdated packages. |
| update.packages | Used to automatically compare the version numbers ofinstalled packages with the newest available version on therepositories and update outdated packages on the fly. |
| upgrade | Summarizes information about installed packages andpackages available at various repositories and automaticallyupgrades outdated packages. |
| url.show | Extension of file.show to display text files froma remote server. |
| vi | Invokes a text editor on an R object. |
| vignette | Views a specified vignette or lists the availableones. |
| write.csv, write.csv2 | Convenience wrappers to write.table for producing CSV filesfrom an R object. |
| write.socket | read.socket reads astring from the specified socket; write.socket writes to the specifiedsocket. There is very little error checking done byeither. |
| write.table | Prints its required argument x (after converting it to a dataframe if it is not one nor a matrix) to a file orconnection. |
| wsbrowser | The browseEnvfunction opens a browser with list of objects currently in thesys.frame()environment. |
| xedit | Invokes the xedit editor on an R object. |
| xemacs | Invokes the xemacs editor on an R object. |
| zip.file.extract | Extracts the file named file from the zip archive, ifpossible, and writes it in a temporary location. |
