Information Technology Reference
In-Depth Information
See Also
These are just the point estimates of the predictions. Use the interval="prediction"
argument of predict to obtain the confidence intervals.
1.25 Accessing the Functions in a Package
Problem
A package installed on your computer is either a standard package or a package down-
loaded by you. When you try using functions in the package, however, R cannot find
them.
Solution
Use either the library function or the require function to load the package into R:
> library( packagename )
Discussion
R comes with several standard packages, but not all of them are automatically loaded
when you start R. Likewise, you can download and install many useful packages from
CRAN, but they are not automatically loaded when you run R. The MASS package comes
standard with R, for example, but you could get this message when using the lda func-
tion in that package:
> lda(x)
Error: could not find function "lda"
R is complaining that it cannot find the lda function among the packages currently
loaded into memory.
When you use the library function or the require function, R loads the package into
memory and its contents immediately become available to you:
> lda(f ~ x + y)
Error: could not find function "lda"
> library(MASS) # Load the MASS library into memory
> lda(f ~ x + y) # Now R can find the function
Call:
lda(f ~ x + y)
Prior probabilities of groups:
.
. (etc.)
.
Before calling library , R does not recognize the function name. Afterward, the package
contents are available and calling the lda function works.
 
Search WWH ::




Custom Search