Watts-College / paf-513-template

https://watts-college.github.io/paf-513-template/
MIT License
0 stars 0 forks source link

Lab03 - Anyone else having trouble installing the Lahman package? #8

Open myungjlee opened 10 months ago

myungjlee commented 10 months ago

As the title says, I'm wasting two days trying to install the "Lahman" package. The error message follows as below:

Install package error message: Installing package(s) at location 'C:/Users/backs/AppData/Local/R/win-library/4.3'. (because 'lib' is not specified) trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/Lahman_11.0-0.zip' Warning in install.packages : URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/Lahman_11.0-0.zip': status was 'SSL connect error' Error in download.file(url, destfile, method, mode = "wb", ...) : cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/Lahman_11.0-0.zip' Warning in install.packages : Failed to download package 'Lahman'

So I tried the following methods to solve it:

Error message when running library(Lahman): Error in library(Lahman) : No package called 'Lahman' found.

So I still cannot start Lab03, because R cannot recognize any data. If anyone else has encountered difficulties installing the package, I'd be grateful if you could share your solution. (The dplyr and pander packages are loaded)

Thank you.

lecy commented 10 months ago

If you are experiencing conflict while installing packages, sometimes it helps to close R Studio, open a basic R Console, and install from there. It often resolves conflicts regarding packages that are locked by R Studio because they are in use.

Although that doesn't seem to be the problem here, note that R Studio defaults to the RStudio CRAN server:

cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/Lahman_11.0-0.zip'

It might just be that their server is down. Try changing your mirror (server location). You can go under Tools >> Install Packages and select a different server. Or just specify a setting in the install function.

install.packages( 'Lahman', repos='http://cran.us.r-project.org' )

List of mirrors

One other idea would be checking your permissions. Does R have permission to write to the AppData drive? Is it your own computer, or does someone else manage you permissions? Do you have an aggressive virus protection program that blocks other apps?

If you have been able to install other package that would likely not be the issue. But it looks like your errors are mostly about the failure to download the package, even trying different approaches, which could be a firewall issue or even just internet speed.

Installing package(s) at location 'C:/Users/backs/AppData/Local/R/win-library/4.3'.
Warning in install.packages :
URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/Lahman_11.0-0.zip': status was 'SSL connect error'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/Lahman_11.0-0.zip'
Warning in install.packages :
Failed to download package 'Lahman'

You might also try changing the download method. This could be related to the bad SSL connection, perhaps if your OS is choosing a weird method.

install.packages( 'Lahman', method='curl' )

# Method to be used for download.file. Currently download methods "internal", "wininet" (Windows only), 
# "libcurl", "wget" and "curl" are available. If not set, method = "auto" is chosen: 
# see [download.file](https://stat.ethz.ch/R-manual/R-devel/library/utils/html/download.file.html).

Worst case, just go to the CRAN page, download a zipped version of the package, and in a base R Console select Packages >> Install Package from Local File.

https://cran.r-project.org/web/packages/Lahman/index.html

myungjlee commented 10 months ago

Thank you so much Professor @lecy !!!

As you just pointed out, I went into Tools >> Install Packages, and then: specified 'Install From' as "Package Archive File (.zip; .tar.gz)", loaded the .tar.gz file that I downloaded manually from CRAN, and all of a sudden, it installed successfully. library(Lahman) also loaded without any problems.

Thank you so much for explaining this in such detail.

lecy commented 10 months ago

It's strange that you were trying the right things and kept getting errors. I suspect it is because Lahman is a large-ish package since it contains a lot of data. I wouldn't be surprised if you kept timing out because of the size.