Installing package from source R
After spending about an hour, thanks to @user20650 and @GWD I was able to solve my problem as follows:
- I previously had R 3.5.3, I upgraded to the latest version 3.6.2
- Steps to upgrade R if you already have it: tutorial 1 and tutorial 2
- After having R 3.6.2, I used
RGui
rather thatRStudio
to installHmisc
- I typed in the GUI console:
install.packages("Hmisc");
it prompts you for a message about compilation, I clicked on NO
How do I install an R package from the source tarball on windows?
I know this is an old question but it came up first in my Google search for this same question, even though I knew the answer I just wanted something to copy and paste. Which makes it worth improving the answer for future reference. So here is what works for me:
Install rtools, then:
install.packages(path_to_file, repos = NULL, type="source")
Installing an R package from local unzipped folder
If it is an unzipped Windows binary (e.g., from CRAN), you can just copy and paste the entire package directory into your library folder. You could also, presumably, use file.copy()
to do so if you wanted to do it within R. install.packages()
is failing (weirdly) because you're giving it something other than the typical package source or zipped binary that it is expecting.
To build an R package from source fails: Win10, RStudio
This is more of a work around than a proper answer. The alternative to installing and building from source is to install a pre-built binary. If one is not available, you can build it remotely.
In this case, for the package of interest for me, rundel/livecode on github, I:
- Forked the repo (in this case rundel/livecode). This step might be optional.
- Downloaded the tar.gz (
remotes::install_github("markbneal/livecode"
) which doesn't install it, but the error tells you where it saves the .tar.gz file locally. - Used rhub to build the package binary for windows, go to this website https://builder.r-hub.io/ and upload your tar.gz file, ensuring rhub has your email address (click "advanced" button to provide your email address as alternate - you will need to validate it). That emails me a zip 5 minutes later.
- Then copy the livecode folder in the zip that is emailed to me to my "R packages" folder location.
Package should now work for you, in my caselibrary(livecode)
Edited six months later when I had to use this process again!
R package long time to install - Source or Binary type
Source installs are the most up-to-date, where binary packages may lag by "some time". This is reflected in your output, where your R-3.6 sees 1.4.6 as the most recent though 1.5.3 source is available.
Some ways around this:
install.packages("stringi", type="binary")
should find the closest version and install it without needing to compile it.Download one of the
.zip
files (since you're on windows) from the CRAN page forstringi
page and then useinstall.packages("path/to/stringi_1.5.3.zip")
. However, they only have binary versions for R-4.0, not for R-3.6 ("r-oldrel"), so ... it may complain, or it may install and fail spectacularly when you most need the package in the future (and are on the plane without an internet connection).According to a blog post on RStudio, you can use their public CRAN-like mirror to install binary packages for: linux (not available on CRAN) and for older releases of R (also not available on CRAN).
In your case, since you said your getOption("pkgType")
is "both"
, that means 'use binary if available and current, otherwise try source' (from ?install.packages
), which matches the 1.4.6-vs-1.5.3 issue I mentioned first.
Related Topics
Creating a New Column Based on Unique Id With Values in R
Find All Combinations of a Set of Numbers That Add Up to a Certain Total
Convert Categorical Variables to Numeric in R
Calculate Row Means on Subset of Columns
How to Italicize Part (One or Two Words) of an Axis Title
How to Make a Great R Reproducible Example
Converting Year and Month ("Yyyy-Mm" Format) to a Date
Showing Data Values on Stacked Bar Chart in Ggplot2
How to Get a Contingency Table
Count Number of Rows in a Data Frame in R Based on Group
How to Read Multiple (Excel) Files into R
Split a Large Dataframe into a List of Data Frames Based on Common Value in Column
Make the Background of a Graph Different Colours in Different Regions
Select the First and Last Row by Group in a Data Frame