Unable to install Leaflet package in R

Hi all,

I am unable to install Leaflet package in R.

>install.packages("leaflet", type = "source")
Installing package into ‘D:/Windows/Analytics/R Programming/GitHub/App/****/****/renv/library/R-4.0/x86_64-w64-mingw32’
(as ‘lib’ is unspecified)
also installing the dependency ‘png’

trying URL 'https://cran.rstudio.com/src/contrib/png_0.1-8.tar.gz'
Content type 'application/x-gzip' length 24880 bytes (24 KB)
downloaded 24 KB

trying URL 'https://cran.rstudio.com/src/contrib/leaflet_2.1.1.tar.gz'
Content type 'application/x-gzip' length 2010129 bytes (1.9 MB)
downloaded 1.9 MB

* installing *source* package 'png' ...
** package 'png' successfully unpacked and MD5 sums checked
** using staged installation
  checking PNG headers and libraries
./configure.win: line 11: E:/Program: No such file or directory
make: E:/Program: No such file or directory
make: E:/Program: No such file or directory
make: *** No rule to make target 'E:/Program'.  Stop.
  LOCAL_SOFT does not exist, fall back to external png
  cannot find current PNG files
  attempting to download them
./configure.win: line 38: E:/Program: No such file or directory

 *** ERROR: unable to find PNG files

 They must be either in src/win32, in a tar-ball
 src/libpng-current-win.tar.gz or
 available via the LOCAL_SOFT R make setting.

 You can get the latest binary tar ball from
 http://www.rforge.net/png/files/

ERROR: configuration failed for package 'png'
* removing 'D:/Windows/Analytics/R Programming/GitHub/App/****/****/renv/library/R-4.0/x86_64-w64-mingw32/png'
ERROR: dependency 'png' is not available for package 'leaflet'
* removing 'D:/Windows/Analytics/R Programming/GitHub/App/****/****/renv/library/R-4.0/x86_64-w64-mingw32/leaflet'

The downloaded source packages are in
	‘C:\Users\vinay\AppData\Local\Temp\Rtmp2fagQ3\downloaded_packages’
Warning messages:
1: In utils::install.packages("leaflet", type = "source") :
  installation of package ‘png’ had non-zero exit status
2: In utils::install.packages("leaflet", type = "source") :
  installation of package ‘leaflet’ had non-zero exit status

I tried to install png as per above message but failed again

> install.packages("png", type = "source")
Installing package into ‘D:/Windows/Analytics/R Programming/GitHub/App/****/****/renv/library/R-4.0/x86_64-w64-mingw32’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/png_0.1-8.tar.gz'
Content type 'application/x-gzip' length 24880 bytes (24 KB)
downloaded 24 KB

* installing *source* package 'png' ...
** package 'png' successfully unpacked and MD5 sums checked
** using staged installation
  checking PNG headers and libraries
./configure.win: line 11: E:/Program: No such file or directory
make: E:/Program: No such file or directory
make: E:/Program: No such file or directory
make: *** No rule to make target 'E:/Program'.  Stop.
  LOCAL_SOFT does not exist, fall back to external png
  cannot find current PNG files
  attempting to download them
./configure.win: line 38: E:/Program: No such file or directory

 *** ERROR: unable to find PNG files

 They must be either in src/win32, in a tar-ball
 src/libpng-current-win.tar.gz or
 available via the LOCAL_SOFT R make setting.

 You can get the latest binary tar ball from
 http://www.rforge.net/png/files/

ERROR: configuration failed for package 'png'
* removing 'D:/Windows/Analytics/R Programming/GitHub/App/****/****/renv/library/R-4.0/x86_64-w64-mingw32/png'

The downloaded source packages are in
	‘C:\Users\vinay\AppData\Local\Temp\Rtmp2fagQ3\downloaded_packages’
Warning message:
In utils::install.packages("png", type = "source") :
  installation of package ‘png’ had non-zero exit status

Can anyone help me here?

Do you have rtools installed?

If not, install it from

https://cran.r-project.org/bin/windows/Rtools/rtools42/rtools.html

then restart RStudio and try installing the required packages.

I have it installed actually. But still same error