2

I'm typing for example:

install.packages('TTR')

output is:

--- Please select a CRAN mirror for use in this session ---
trying URL 'http://mirrors.softliste.de/cran/bin/windows/contrib/2.12/TTR_0.20-2.zip'
Content type 'application/zip' length 237131 bytes (231 Kb)
opened URL
downloaded 231 Kb

package 'TTR' successfully unpacked and MD5 sums checked

The downloaded packages are in
        C:\Documents and Settings\Administrator\Local Settings\Temp\Rtmp33oIzT\downloaded_packages

But then, even after restarting environment functions belonging to that package aren't recognized, for example EMA() -> Error: could not find function "EMA". Is there any command command to actually install these downloaded packages.

There is "R CMD INSTALL" command to use in shell but when I type:

R CMD INSTALL TTR

I get:

Warning: invalid package 'TTR'
Error: ERROR: no packages specified
mbq
  • 18,510
  • 6
  • 49
  • 72
rsk82
  • 28,217
  • 50
  • 150
  • 240
  • 2
    Did you load the library in your R script? `library(TTR)` – Chase Dec 11 '10 at 17:59
  • Well, that was the problem, thanks. Sorry for maybe stupid question, but in all searching I have done there was not said that the library must be loaded. I just assumed that the environment automatically loads given library when function is called. – rsk82 Dec 11 '10 at 18:06
  • 2
    +1 as I see no reason for a downvote here: question was clear, OP was polite. – Dancrumb Dec 11 '10 at 18:10
  • 3
    @user393087 installed packages aren't automatically loaded as many contributed packages have functions with the same name. This would be very confusing to the user if they didn't play an active part in loading the libraries so they knew which packages was loaded last. – Sharpie Dec 11 '10 at 19:22

2 Answers2

4

As hinted at in the comment, installing and gaining access to packages is a two step process. You've got the first step down with install.packages() but then you also need to load the library in your R script to gain access to those functions with library(YourPackageHere).

See this question for other details.

Community
  • 1
  • 1
Chase
  • 67,710
  • 18
  • 144
  • 161
  • 6
    this is also FAQ 7.30 in the R FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#I-installed-a-package-but-the-functions-are-not-there – Ben Bolker Dec 11 '10 at 18:48
  • how to install `R package` along with it's dependencies from a zip file, that is downloaded from official repository? – Banee Ishaque K Jul 31 '17 at 15:34
4

A copy of An Introduction to R comes with your R installation. Had you glanced at the Table of Contents, you would have seen the Packages section, where your question is answered in the second sentence.

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418