Install magick/summarytools [duplicate] - r

I want to use ImageMagick in R, but R won't let me install it.
install.packages("ImageMagick")
Installing package into ‘C:/Users/FSFH-2/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
Warning message:
package ‘ImageMagick’ is not available (for R version 3.0.1)
I'm under the impression that I have the latest version of R, so what's going on here?
Additionally, I downloaded ImageMagick into windows, but I can't figure out how to get it into R. Help!

you need to install a package named "installr" prior to installing ImageMagick.
Simple Steps:
Tools->InstallPackages->installr
From R command Line write
require(installr)
install.ImageMagick() (This command will by default install the latest version, u can specify the URl of the version needed)
The package will be installed !!!

There is now a package magick that wraps around the ImageMagick STL.
It can be installed simply with install.packages("magick")
There is a blog post explaining what you can do with it here: https://ropensci.org/blog/2016/08/23/z-magick-release

Just follow the link Link to download and install ImageMagick on Windows. After that, type your command (like convert ...) in cmd.exe to verify that ImageMagick does exist. At this time, I know that we can only use it in cmd.exe, not in R.

If you are on Mac, what just worked for me was to use Homebrew in Terminal (if you don't have homebrew or anything similar, get it!).
I installed ImageMagick, and then I had to install animation in R itself.
In terminal:
sudo brew install ImageMagick
... it installs a few package dependencies and finishes up.
In the R console afterwards (in R, Rstudio, Emacs, ...):
install.packages("animation")
Now try ?gganimate and run the examples at the bottom to test it out!
The examples in the help file worked without problem for me. This works within Rstudio very fluidly, Rstudio being written just as a web-browser is under the hood. I personally use ESS within Emacs, which for plotting usually opens an X11 (or Quartz) window. Using gg_animate, however, opens a browser by default and displays the output there.

I used these commands in RStudio.
install.packages('installr')
library(installr)
install.ImageMagick()
It installed the latest version of ImageMagick.

If you're using Mac OS or Linux, you can install ImageMagick on your system and then use it from within R using the system() function. I don't know if ImageMagick works with Windows.

If you are on Mac, what just worked for me was to use port in Terminal.
I installed ImageMagick, and then I had to install animation in R itself.
In terminal:
sudo port install ImageMagick
... it installs a few package dependencies and finishes up.
In the R studio afterwards:
install.packages("animation")
and then check by running following example:
saveGIF({
for (i in 1:10) plot(runif(10), ylim = 0:1)
})
if the above conversion was successful, the option 'convert' should not be NULL

Related

Cannot install R packages in Jupyter Notebook

I am trying to run R code in Jupyter and the R Kernel was added. Most of the time, packages can be installed successfully. However, some of the packages, such as RCurl and ggmap, would got error while installing.
Example:
install.packages("RCurl")
Warning message in install.packages("RCurl"):
“installation of package ‘RCurl’ had non-zero exit status”Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
What should I do?
Try to specify CRAN as repository in your install.packages statement when installing RCurl and ggmap. For example:
install.packages("RCurl", repos='http://cran.us.r-project.org')
This Stack Overflow post on installing R packages through Anaconda/Jupyter beyond those included in R essential provides more detail.
(Side note: I had encountered the same issue when trying to install R packages on computer clusters. This solution worked for me.)
use conda comment:
conda install r-RCurl
I kept getting the non-zero exit status when trying to install packages with Jupyter notebook with R kernel and was failing because of multiple dependencies when wanting to install a package. I am not an expert in any of these so please forgive me if I make an error in explaining or if it is a non-issue for you but please feel free to comment to clear things out. I just want to share my success story so hopefully it can help someone else: I am working on a MacBook Pro. Here are the information I get when I run R.version() on my jupyter notebook with R kernel:
$platform 'x86_64-conda_cos6-linux-gnu'
$arch 'x86_64'
$os 'linux-gnu'
$system 'x86_64, linux-gnu'
$language 'R'
$version.string 'R version 3.6.1 (2019-07-05)'
These are the steps to take to fix the issue:
Go to https://anaconda.org/
Search the package name that you are trying to install
Copy the one line that is given to install the package, it should be something like:
Conda install -c r r-caret #conda install -c r r-package_name
NOTE: sometimes during installing packages, you’re asked whether or not you want to continue, so add --y at the end of the above statement to continue, so something like this
Conda install -c r r-caret --y
(I will always add it just to be on the safe side)
Click on the new launcher (+ icon) to create a new notebook with PySpark (once opened it has .ipynp extension)
On the first cell paste the copied line from step 2 and run
Once done, restart the kernel on the current notebook
Restart the kernel on your other notebook with R kernel
Run library(package_name) on your notebook with R kernel (e.x. library(caret))
install.packages("Hmisc", .libPaths(), repos='http://cran.us.r-project.org')
This command will install the packagae in the conda
"/home/user/anaconda3/lib/R/library" and use the cran r repository as source.
Add path in Anaconda
As per this answer,
one can also add additional paths in anaconda to load libraries from (for eg., the location where R studio saves the user-installed packages) with
.libPaths( c( .libPaths(), "~/userLibrary") )
For example, the following worked for me:
In Anaconda :
.libPaths( c( .libPaths(), "C:\Users\name\Documents\R\win-library\3.5") )
When I tried to add anaconda's library path to RStudio, it resulted in errors (The procedure entry point MARK_NOT_MUTABLE could not be located in the dynamic link library << arose 4 times in succession) after installation of a package, though the package seemed to load.
Replace name with your local user folder name
Add/change path in RStudio
A useful link to make changes in default user-installed library paths :
https://www.accelebrate.com/library/how-to-articles/r-rstudio-library
To find out where a package has been installed:
find.package('package_name')
The directions nobody else supplied worked for me, but I found this guide, and it worked. Spent way too much time trying all these when I just needed a few simple commands. https://developers.refinitiv.com/en/article-catalog/article/setup-jupyter-notebook-r
I already had R and python installed, so I skipped to step 3. The only seems to mention windows, but it worked for me on mac as well. After following them I was able to install the packages using install.packages("dplyr", repos = "http://cran.us.r-project.org") in a cell in jupyter.
You have to create a directory in which your package will be and do for eg:
install.packages('ggplot2',loc='your directory')
First Step: You can install the IRkernel packages by running the following command in an R console:install.packages('IRkernel')
Second Step: You will have to make Jupyter see the newly installed R kernel by installing a kernel spec. To install system-wide, set user to False in the installspec command IRkernel::installspec(user = FALSE)
Setup Jupyter Notebook for R

how to install/update a package from source inside cygwin

new to Cygwin. I downloaded apg-cyg and have been using it to install packages.
Recently I installed R and the current version in Cygwin packages is R.3.2.4. I wanted to install the latest R package but couldn't find a way from googling on how to do it inside Cygwin.
Is this possible to do or I just have to wait for the Cygwin packages updating their packages to the latest version? It would be nice to be able to update a package using the source file inside Cygwin..
Edit:
I should mention that I tried to install ggplot2 inside R using install.packages() and there was non-zero exit status and the installation couldn't go through.
You can install the source using cygwin setup. Click on the mouse on the "Src?" column.
The source will be installed in /usr/src
PS: next R release 3.3.1 is in 11 days. It will be packed for cygwin if there are no build issue
Followup:
There were several build issues, it took longer than expected to build 3.3.1
https://www.cygwin.com/ml/cygwin-announce/2016-06/msg00056.html

Homebrew install R without Xquartz on OS X

Installing R with the pkg installer doesn't require XQuartz. However, install R with Homebrew requires to install XQuartz first.
Can anybody explain why please?
Is there a way to install R without Xquartz with Homebrew?
I need to decide whether to use Homebrew, or install R, Python etc with their pkg installers before applying to multiple computers (running OS X 10.8).
If you look at the recipe you'll see you can pass --without-x11 as a parameter (which should remove the need to have XQuartz installed. There is a cask for xquartz, btw. There is a recipe for R GUI, as well.
Homebrew R has had some issues with RStudio in the past and is also not recommended by the R maintainers.
According to this commit on GitHub, it has been fixed.
r: fix build with Quartz-only cairo #2434
Now, XQuartz is not required anymore, tested and it works:
brew update
brew tap homebrew/science
brew install r
I found that R works just fine without x.11 until I wanted to use the simple text editor. It complained about not having x.11, and wanted xquartz. I installed xquartz from home-brew and RStudio (and R) worked just fine. Hope that's useful.

Can we install a `.zip` R package under linux?

I have found an old R package with a .zip extension on my PC.
I would like to run it, but I do not have the tar.gz that was used to
create it and I use linux. What are my options?
Few, essentially.
A .zip package for R is almost surely a binary built for Windows so you need to find a suitable Windows computer -- or emulator -- to use it.
So, this can be done this way:
install wine (wine is not an emulator),
install R for Windows, which you download manually from CRAN
install the zip package using the usual commands (install.packages("filename.zip",source=NULL)). You will probably get error messages for the dependencies, but incrementally installing those, it should work.

How do I install an R package from the source tarball on windows?

The forecast package for R has been updated to version 2.12, but there are currently only windows binarys for 2.11 available on CRAN.
How do I install an R package from the source 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")
Two answers that may help you avoid the hassle of installing Rtools.
Use http://win-builder.r-project.org/ to build a binary version, download it, and install (using install.packages(...,repos=NULL))
If the package has no binary component (i.e. no src directory with C, C++, or Fortran code that needs to be compiled during installation (not true for forecast, but possibly useful some other time) then simply specifying type="source" within the install.packages call (whether from a repository or a local copy of the source tarball (.tar.gz file)) will install the source package, even on Windows.
Start by reviewing the section on Windows packages in the R Installation and Administration manual, then carefully follow the instructions from The Windows toolset appendix.
I know it's usually bad form to mainly provide links in an answer, but these are links to the canonical references on this topic. I simply link to them rather than summarize their contents, since they should be accurate for the most current R release.
I'm not sure if this is the best way, but I found the following method to work (based in part on the answers above):
1) Download the package .tar
2) Move the package to the directory with your user R libraries (e.g., in my case it was "C:/Users/yourUserName/Documents/R/win-library/3.3")
3) Within Rstudio (or elsewhere, probably), run the command... install.packages("packageName.tar", repos=NULL, type="source")
That worked for me at least. Hope it's helpful!
Download the package *.tar.gz.
make sure you have Rtools installed.
Make sure the R and Rtools paths are added in the environment varialble.
Open a command prompt. Type R CMD INSTALL packagename.tar.gz.
it will work i hope.
To install a package from a .tar.gz file, follow these steps:
Launch R to have the R command prompt
Type: install.packages(<path_to_tar.gz_file>, repos = NULL)
or launch directly:
R CMD INSTALL <path_to_.tar.gz_file>
You need to have R installed but you don't need RTools

Resources