R Packages: Difference between revisions

From Wiki
Jump to navigation Jump to search
Created page with 'To use a package, it must first be installed on the system. Then you load it into your current session. To get the list of packages loaded by default: <pre> > getOption("defaul…'
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 14: Line 14:
<pre>
<pre>
(.packages(all.available=TRUE))
(.packages(all.available=TRUE))
</pre>
To install a package:
<pre>
install.packages("pkg1")            # for a single package
install.packages(c("pkg1", "pkg2"))  # for multiple packages
</pre>
</pre>


Line 19: Line 25:
<pre>
<pre>
> library(rpart)
> library(rpart)
</pre>
To see the version of a package:
<pre>
packageVersion("afex")
</pre>
</pre>

Latest revision as of 16:48, 17 July 2017

To use a package, it must first be installed on the system. Then you load it into your current session.

To get the list of packages loaded by default:

> getOption("defaultPackages")

To see the list of currently loaded packages:

> (.packages())

To show all available packages:

(.packages(all.available=TRUE))

To install a package:

install.packages("pkg1")             # for a single package
install.packages(c("pkg1", "pkg2"))  # for multiple packages

To load a package:

> library(rpart)

To see the version of a package:

packageVersion("afex")