Error when library ggplot2 and survminer - r

I have the following error when I'm using the ggplot2 and survminer packages.
I really have no idea why the warning appeared.
> install.packages(c("survival", "survminer", "ggplot2"))
Installing packages into ‘C:/Users/xu081/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.4/survival_2.42-3.zip'
Content type 'application/zip' length 4584781 bytes (4.4 MB)
downloaded 4.4 MB
trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.4/survminer_0.4.2.zip'
Content type 'application/zip' length 2849057 bytes (2.7 MB)
downloaded 2.7 MB
trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.4/ggplot2_2.2.1.zip'
Content type 'application/zip' length 2784778 bytes (2.7 MB)
downloaded 2.7 MB
package ‘survival’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘survival’
package ‘survminer’ successfully unpacked and MD5 sums checked
package ‘ggplot2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\xu081\AppData\Local\Temp\RtmpuOtZaF\downloaded_packages
> library(survival)
> library(ggplot2)
Error in UseMethod("conditionCall") :
no applicable method for 'conditionCall' applied to an object of class "character"
> library(survminer)
载入需要的程辑包:ggplot2
Error in UseMethod("conditionCall") :
no applicable method for 'conditionCall' applied to an object of class "character"
> install.packages("devtools")
Installing package into ‘C:/Users/xu081/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.4/devtools_1.13.5.zip'
Content type 'application/zip' length 443954 bytes (433 KB)
downloaded 433 KB
package ‘devtools’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\xu081\AppData\Local\Temp\Rtmpa62LXv\downloaded_packages
> library(devtools)
> devtools::install_github("tidyverse/ggplot2")
Downloading GitHub repo tidyverse/ggplot2#master
from URL https://api.github.com/repos/tidyverse/ggplot2/zipball/master
Installing ggplot2
"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" --no-site-file --no-environ --no-save no-restore --quiet CMD INSTALL \
"C:/Users/xu081/AppData/Local/Temp/Rtmpa62LXv/devtools1dac50bf8ef/tidyverse-ggplot2-4463da6" \
--library="C:/Users/xu081/Documents/R/win-library/3.4" --install-tests
* installing *source* package 'ggplot2' ...
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** preparing package for lazy loading
Error in UseMethod("conditionCall") :
"conditionCall"没有适用于"character"目标对象的方法
* removing 'C:/Users/xu081/Documents/R/win-library/3.4/ggplot2'
* restoring previous 'C:/Users/xu081/Documents/R/win-library/3.4/ggplot2'
In R CMD INSTALL
Error in UseMethod("conditionMessage") :
no applicable method for 'conditionMessage' applied to an object of class
"character"
I really appreciate your answers.

Related

Unable to load an installed package in R

While trying to install and load the package Hmisc in RStudio, I ran into an error. Upon inspection, it turned out to originate from ggplot2. I can replicate the error on my machine as follows:
> install.packages("ggplot2", dependencies=TRUE)
# see bottom of this post for the full log of this command.
> library(ggplot2)
Error in library(ggplot2) : there is no package called 'ggplot2'
I have reinstalled RStudio and its packages, but without success. Also, some other packages (such as AER) do work properly.
Any advice on how to solve this issue would be greatly appreciated.
Full log of install.packages("ggplot2"):
Installing package into <some library>
(as ‘lib’ is unspecified)
also installing the dependencies ‘cli’, ‘rlang’, ‘lifecycle’, ‘scales’
There are binary versions available but the source versions are later:
binary source needs_compilation
cli 3.2.0 3.4.1 TRUE
rlang 1.0.2 1.0.6 TRUE
lifecycle 1.0.1 1.0.3 FALSE
scales 1.2.0 1.2.1 FALSE
ggplot2 3.3.5 3.3.6 FALSE
Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/cli_3.2.0.zip'
Content type 'application/zip' length 1255499 bytes (1.2 MB)
downloaded 1.2 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/rlang_1.0.2.zip'
Content type 'application/zip' length 1718546 bytes (1.6 MB)
downloaded 1.6 MB
package ‘cli’ successfully unpacked and MD5 sums checked
package ‘rlang’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
<some library>
installing the source packages ‘lifecycle’, ‘scales’, ‘ggplot2’
trying URL 'https://cran.rstudio.com/src/contrib/lifecycle_1.0.3.tar.gz'
Content type 'application/x-gzip' length 106854 bytes (104 KB)
downloaded 104 KB
trying URL 'https://cran.rstudio.com/src/contrib/scales_1.2.1.tar.gz'
Content type 'application/x-gzip' length 270609 bytes (264 KB)
downloaded 264 KB
trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.3.6.tar.gz'
Content type 'application/x-gzip' length 3061989 bytes (2.9 MB)
downloaded 2.9 MB
* installing *source* package 'lifecycle' ...
** package 'lifecycle' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'rlang' 1.0.2 is being loaded, but >= 1.0.6 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'lifecycle'
* removing <some library>
Warning in install.packages :
installation of package ‘lifecycle’ had non-zero exit status
ERROR: dependency 'lifecycle' is not available for package 'scales'
* removing <some library>
Warning in install.packages :
installation of package ‘scales’ had non-zero exit status
ERROR: dependency 'scales' is not available for package 'ggplot2'
* removing <some library>
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
The downloaded source packages are in
<some library>
After being advised to install rlang, I first ran remove.packages(rlang), and then install.packages("rlang"), type="source"). However, when I then run library(rlang), I get the error Error in library(rlang) : there is no package called ‘rlang’. Here is the output of install.packages("rlang"):
Installing package into < some library >
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rlang_1.0.6.tar.gz'
Content type 'application/x-gzip' length 742508 bytes (725 KB)
downloaded 725 KB
* installing *source* package 'rlang' ...
** package 'rlang' successfully unpacked and MD5 sums checked
** using staged installation
** libs
*** arch - i386
Warning in system(cmd) : 'make' not found
ERROR: compilation failed for package 'rlang'
* removing < some library >
Warning in install.packages :
installation of package ‘rlang’ had non-zero exit status
The downloaded source packages are in
< some library >

ggplot not installing - tried everything

I'm out of options to install ggplot. I tried installing from Tools, from the console itself, indicating the cran source, indicating the local dir that the ggplot.gz file appears in. None of them works. I tried installing devtools first but same issue with that package too. I still get the error as follows:
install.packages("ggplot2")
Installing package into ‘\\corp.bloomberg.com/ny-dfs/Users/asadeghi8/R/win-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘lifecycle’, ‘rlang’, ‘scales’, ‘withr’
There are binary versions available but the source versions are later:
binary source needs_compilation
lifecycle 0.2.0 1.0.1 FALSE
rlang 0.4.5 1.0.2 TRUE
scales 1.1.0 1.2.0 FALSE
withr 2.2.0 2.5.0 FALSE
ggplot2 3.3.0 3.3.6 FALSE
Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rlang_0.4.5.zip'
Content type 'application/zip' length 1115838 bytes (1.1 MB)
downloaded 1.1 MB
package ‘rlang’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\asadeghi8\AppData\Local\Temp\RtmpY96UwM\downloaded_packages
installing the source packages ‘lifecycle’, ‘scales’, ‘withr’, ‘ggplot2’
trying URL 'https://cran.rstudio.com/src/contrib/lifecycle_1.0.1.tar.gz'
Content type 'application/x-gzip' length 99716 bytes (97 KB)
downloaded 97 KB
trying URL 'https://cran.rstudio.com/src/contrib/scales_1.2.0.tar.gz'
Content type 'application/x-gzip' length 270188 bytes (263 KB)
downloaded 263 KB
trying URL 'https://cran.rstudio.com/src/contrib/withr_2.5.0.tar.gz'
Content type 'application/x-gzip' length 102089 bytes (99 KB)
downloaded 99 KB
trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.3.6.tar.gz'
Content type 'application/x-gzip' length 3061989 bytes (2.9 MB)
downloaded 2.9 MB
* installing *source* package 'lifecycle' ...
** package 'lifecycle' successfully unpacked and MD5 sums checked
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'rlang' 0.4.5 is being loaded, but >= 0.4.10 is required
ERROR: lazy loading failed for package 'lifecycle'
* removing '\\corp.bloomberg.com/ny-dfs/Users/asadeghi8/R/win-library/3.5/lifecycle'
In R CMD INSTALL
Warning in install.packages :
installation of package ‘lifecycle’ had non-zero exit status
* installing *source* package 'withr' ...
** package 'withr' successfully unpacked and MD5 sums checked
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'withr'
finding HTML links ... done
defer html
devices html
Rd warning: C:/Users/asadeghi8/AppData/Local/Temp/RtmpIN8vq1/R.INSTALL987c3eca7587/withr/man/devices.Rd:228: file link 'X11' in package 'grDevices' does not exist and so has been treated as a topic
makevars_user html
set_makevars html
with_ html
with_collate html
with_connection html
with_db_connection html
with_dir html
with_envvar html
with_file html
with_gctorture2 html
with_language html
with_libpaths html
with_locale html
with_makevars html
with_options html
with_package html
Rd warning: C:/Users/asadeghi8/AppData/Local/Temp/RtmpIN8vq1/R.INSTALL987c3eca7587/withr/man/with_package.Rd:68: file link '.libPaths' in package 'base' does not exist and so has been treated as a topic
with_par html
with_path html
with_rng_version html
with_seed html
with_sink html
with_temp_libpaths html
with_tempfile html
with_timezone html
withr html
*** copying figures
** building package indices
** installing vignettes
Warning in file(con, "w") :
cannot open file '\\corp.bloomberg.com/ny-dfs/Users/asadeghi8/R/win-library/3.5/withr/doc/index.html': No such file or directory
Error in file(con, "w") : cannot open the connection
ERROR: installing vignettes failed
* removing '\\corp.bloomberg.com/ny-dfs/Users/asadeghi8/R/win-library/3.5/withr'
In R CMD INSTALL
Warning in install.packages :
installation of package ‘withr’ had non-zero exit status
ERROR: dependency 'lifecycle' is not available for package 'scales'
* removing '\\corp.bloomberg.com/ny-dfs/Users/asadeghi8/R/win-library/3.5/scales'
In R CMD INSTALL
Warning in install.packages :
installation of package ‘scales’ had non-zero exit status
ERROR: dependencies 'scales', 'withr' are not available for package 'ggplot2'
* removing '\\corp.bloomberg.com/ny-dfs/Users/asadeghi8/R/win-library/3.5/ggplot2'
In R CMD INSTALL
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\asadeghi8\AppData\Local\Temp\RtmpY96UwM\downloaded_packages’
> library("ggplot")
Error in library("ggplot") : there is no package called ‘ggplot’
I tried to update the rlang package but it when I install it again, it's the same version. This is how it's installed:
> install.packages("rlang")
Installing package into ‘\\corp.bloomberg.com/ny-dfs/Users/asadeghi8/R/win-library/3.5’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
rlang 0.4.5 1.0.2 TRUE
Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rlang_0.4.5.zip'
Content type 'application/zip' length 1115838 bytes (1.1 MB)
downloaded 1.1 MB
package ‘rlang’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\asadeghi8\AppData\Local\Temp\RtmpwpTtFm\downloaded_packages

Non-zero exit status tidyverse install packages Rstudio

I have been roaming the internet trying to find a solution, but haven't found it yet.
My problem is: i can't install tidytext. I also found out I can't re-install tidyverse for some reason.
The error code is:
install.packages("tidytext")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/maria/OneDrive/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
dependency ‘ISOcodes’ is not available
also installing the dependency ‘stopwords’
There is a binary version available but the source
version is later:
binary source needs_compilation
stopwords 0.9.0 1.0 FALSE
installing the source packages ‘stopwords’, ‘tidytext’
trying URL 'https://cran.rstudio.com/src/contrib/stopwords_1.0.tar.gz'
Content type 'application/x-gzip' length 104532 bytes (102 KB)
downloaded 102 KB
trying URL 'https://cran.rstudio.com/src/contrib/tidytext_0.2.2.tar.gz'
Content type 'application/x-gzip' length 3088493 bytes (2.9 MB)
downloaded 2.9 MB
ERROR: dependency 'ISOcodes' is not available for package 'stopwords'
* removing 'C:/Users/maria/OneDrive/Documents/R/win-library/3.4/stopwords'
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "C:\Users\maria\OneDrive\Documents\R\win-library\3.4" C:\Users\maria\AppData\Local\Temp\RtmpOUYnrR/downloaded_packages/stopwords_1.0.tar.gz' had status 1
Warning in install.packages :
installation of package ‘stopwords’ had non-zero exit status
ERROR: dependency 'stopwords' is not available for package 'tidytext'
* removing 'C:/Users/maria/OneDrive/Documents/R/win-library/3.4/tidytext'
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "C:\Users\maria\OneDrive\Documents\R\win-library\3.4" C:\Users\maria\AppData\Local\Temp\RtmpOUYnrR/downloaded_packages/tidytext_0.2.2.tar.gz' had status 1
Warning in install.packages :
installation of package ‘tidytext’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\maria\AppData\Local\Temp\RtmpOUYnrR\downloaded_packages’
> install.packages("tidyverse")
Error in install.packages : Updating loaded packages
Restarting R session...
> install.packages("tidyverse")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/maria/OneDrive/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependencies ‘ellipsis’, ‘vctrs’, ‘lifecycle’, ‘dplyr’, ‘haven’, ‘hms’, ‘purrr’, ‘rlang’, ‘tibble’, ‘tidyr’, ‘xml2’
There are binary versions available but the source
versions are later:
binary source needs_compilation
ellipsis 0.1.0 0.3.0 TRUE
vctrs 0.1.0 0.2.2 TRUE
dplyr 0.8.0.1 0.8.4 TRUE
haven 2.1.0 2.2.0 TRUE
hms 0.4.2 0.5.3 FALSE
purrr 0.3.2 0.3.3 TRUE
rlang 0.3.4 0.4.4 TRUE
tibble 2.1.1 2.1.3 TRUE
tidyr 0.8.3 1.0.2 TRUE
xml2 1.2.0 1.2.2 TRUE
tidyverse 1.2.1 1.3.0 FALSE
Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/ellipsis_0.1.0.zip'
Content type 'application/zip' length 30847 bytes (30 KB)
downloaded 30 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/vctrs_0.1.0.zip'
Content type 'application/zip' length 499748 bytes (488 KB)
downloaded 488 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/dplyr_0.8.0.1.zip'
Content type 'application/zip' length 3029353 bytes (2.9 MB)
downloaded 2.9 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/haven_2.1.0.zip'
Content type 'application/zip' length 988500 bytes (965 KB)
downloaded 965 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/purrr_0.3.2.zip'
Content type 'application/zip' length 327437 bytes (319 KB)
downloaded 319 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/rlang_0.3.4.zip'
Content type 'application/zip' length 1080437 bytes (1.0 MB)
downloaded 1.0 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/tibble_2.1.1.zip'
Content type 'application/zip' length 238931 bytes (233 KB)
downloaded 233 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/tidyr_0.8.3.zip'
Content type 'application/zip' length 907112 bytes (885 KB)
downloaded 885 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/xml2_1.2.0.zip'
Content type 'application/zip' length 3543977 bytes (3.4 MB)
downloaded 3.4 MB
package ‘ellipsis’ successfully unpacked and MD5 sums checked
package ‘vctrs’ successfully unpacked and MD5 sums checked
package ‘dplyr’ successfully unpacked and MD5 sums checked
package ‘haven’ successfully unpacked and MD5 sums checked
package ‘purrr’ successfully unpacked and MD5 sums checked
package ‘rlang’ successfully unpacked and MD5 sums checked
package ‘tibble’ successfully unpacked and MD5 sums checked
package ‘tidyr’ successfully unpacked and MD5 sums checked
package ‘xml2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\maria\AppData\Local\Temp\Rtmpi6CSjp\downloaded_packages
installing the source packages ‘lifecycle’, ‘hms’, ‘tidyverse’
trying URL 'https://cran.rstudio.com/src/contrib/lifecycle_0.1.0.tar.gz'
Content type 'application/x-gzip' length 150752 bytes (147 KB)
downloaded 147 KB
trying URL 'https://cran.rstudio.com/src/contrib/hms_0.5.3.tar.gz'
Content type 'application/x-gzip' length 134669 bytes (131 KB)
downloaded 131 KB
trying URL 'https://cran.rstudio.com/src/contrib/tidyverse_1.3.0.tar.gz'
Content type 'application/x-gzip' length 712837 bytes (696 KB)
downloaded 696 KB
* installing *source* package 'lifecycle' ...
** package 'lifecycle' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'rlang' 0.3.4 is being loaded, but >= 0.4.0 is required
ERROR: lazy loading failed for package 'lifecycle'
* removing 'C:/Users/maria/OneDrive/Documents/R/win-library/3.4/lifecycle'
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "C:\Users\maria\OneDrive\Documents\R\win-library\3.4" C:\Users\maria\AppData\Local\Temp\Rtmpi6CSjp/downloaded_packages/lifecycle_0.1.0.tar.gz' had status 1
Warning in install.packages :
installation of package ‘lifecycle’ had non-zero exit status
* installing *source* package 'hms' ...
** package 'hms' successfully unpacked and MD5 sums checked
** R
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'vctrs' 0.1.0 is being loaded, but >= 0.2.1 is required
ERROR: lazy loading failed for package 'hms'
* removing 'C:/Users/maria/OneDrive/Documents/R/win-library/3.4/hms'
* restoring previous 'C:/Users/maria/OneDrive/Documents/R/win-library/3.4/hms'
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "C:\Users\maria\OneDrive\Documents\R\win-library\3.4" C:\Users\maria\AppData\Local\Temp\Rtmpi6CSjp/downloaded_packages/hms_0.5.3.tar.gz' had status 1
Warning in install.packages :
installation of package ‘hms’ had non-zero exit status
* installing *source* package 'tidyverse' ...
** package 'tidyverse' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace 'haven' 2.1.0 is being loaded, but >= 2.2.0 is required
ERROR: lazy loading failed for package 'tidyverse'
* removing 'C:/Users/maria/OneDrive/Documents/R/win-library/3.4/tidyverse'
* restoring previous 'C:/Users/maria/OneDrive/Documents/R/win-library/3.4/tidyverse'
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "C:\Users\maria\OneDrive\Documents\R\win-library\3.4" C:\Users\maria\AppData\Local\Temp\Rtmpi6CSjp/downloaded_packages/tidyverse_1.3.0.tar.gz' had status 1
Warning in install.packages :
installation of package ‘tidyverse’ had non-zero exit status
I thought the issue was dependencies, but it's not in the error message/output.
Because of the Rtools warning, I have downloaded Rtools, which never was required before - but I get this:
> install.packages("Rtools")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/maria/OneDrive/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘Rtools’ is not available (for R version 3.4.4)
My R / system info: [Default] [64-bit] C:\Program Files\R\R-3.4.4
I work on a Microsoft computer.
Hope someone knows what's what here!
Best,
Maria
#MrFlick posted the answer in the section above:
I had the old version of R. Installed to R 3.6.0 and everything works.
I first only updated Rstudio, not R itself. It wasn't until I updated R that it worked.
Find the link here: https://cran.r-project.org/bin/windows/base/old/3.6.0/

RMD packages can't be downloaded in R Studio

I can't download the RMD packages in R studio. I tried it by running install.packages("rmarkdown"), and I tried it by File > New File > R Markdown > Download packages.
This is the output:
> install.packages("rmarkdown")
Installing package into ‘C:/Users/Luke/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
also installing the dependencies ‘glue’, ‘stringi’, ‘knitr’, ‘yaml’, ‘stringr’
There are binary versions available but the source versions are later:
binary source needs_compilation
glue 1.0.0 1.3.1 TRUE
stringi 1.1.5 1.4.3 TRUE
knitr 1.15.1 1.23 FALSE
yaml 2.1.14 2.2.0 TRUE
stringr 1.2.0 1.4.0 FALSE
rmarkdown 1.4 1.13 FALSE
Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/glue_1.0.0.zip'
Content type 'application/zip' length 34947 bytes (34 KB)
downloaded 34 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/stringi_1.1.5.zip'
Content type 'application/zip' length 14220135 bytes (13.6 MB)
downloaded 13.6 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/yaml_2.1.14.zip'
Content type 'application/zip' length 180051 bytes (175 KB)
downloaded 175 KB
package ‘glue’ successfully unpacked and MD5 sums checked
package ‘stringi’ successfully unpacked and MD5 sums checked
package ‘yaml’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Luke\AppData\Local\Temp\Rtmpq6rTgq\downloaded_packages
installing the source packages ‘knitr’, ‘stringr’, ‘rmarkdown’
trying URL 'https://cran.rstudio.com/src/contrib/knitr_1.23.tar.gz'
Content type 'application/x-gzip' length 880134 bytes (859 KB)
downloaded 859 KB
trying URL 'https://cran.rstudio.com/src/contrib/stringr_1.4.0.tar.gz'
Content type 'application/x-gzip' length 135777 bytes (132 KB)
downloaded 132 KB
trying URL 'https://cran.rstudio.com/src/contrib/rmarkdown_1.13.tar.gz'
Content type 'application/x-gzip' length 3155180 bytes (3.0 MB)
downloaded 3.0 MB
* installing *source* package 'stringr' ...
** package 'stringr' successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'stringi' 1.1.5 is being loaded, but >= 1.1.7 is required
ERROR: lazy loading failed for package 'stringr'
* removing 'C:/Users/Luke/Documents/R/win-library/3.2/stringr'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.3/bin/i386/R" CMD INSTALL -l "C:\Users\Luke\Documents\R\win-library\3.2" C:\Users\Luke\AppData\Local\Temp\Rtmpq6rTgq/downloaded_packages/stringr_1.4.0.tar.gz' had status 1
Warning in install.packages :
installation of package ‘stringr’ had non-zero exit status
ERROR: dependency 'stringr' is not available for package 'knitr'
* removing 'C:/Users/Luke/Documents/R/win-library/3.2/knitr'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.3/bin/i386/R" CMD INSTALL -l "C:\Users\Luke\Documents\R\win-library\3.2" C:\Users\Luke\AppData\Local\Temp\Rtmpq6rTgq/downloaded_packages/knitr_1.23.tar.gz' had status 1
Warning in install.packages :
installation of package ‘knitr’ had non-zero exit status
ERROR: dependencies 'knitr', 'stringr' are not available for package 'rmarkdown'
* removing 'C:/Users/Luke/Documents/R/win-library/3.2/rmarkdown'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.3/bin/i386/R" CMD INSTALL -l "C:\Users\Luke\Documents\R\win-library\3.2" C:\Users\Luke\AppData\Local\Temp\Rtmpq6rTgq/downloaded_packages/rmarkdown_1.13.tar.gz' had status 1
Warning in install.packages :
installation of package ‘rmarkdown’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\Luke\AppData\Local\Temp\Rtmpq6rTgq\downloaded_packages’
The C:\Users\Luke\AppData\Local\Temp\Rtmpq6rTgq\downloaded_packages folder contains:
Screenshot of named folder
I am very inexperienced with programming in R, so I have no idea what to do with this. I am learning to do it (via the online Udacity course), and for that I need these RMD packages to continue. I hope someone can help me.

Why R packages are removed after updating them?

I was trying to update some R packages since RStudio showed they could be updated. After updating, two packages are simply removed. (rgdal and spatstat). The same thing has happened several times recently. What is happening here?
> install.packages(c("data.table", "rgdal", "spatstat"))
Installing packages into ‘C:/Users/Patrick/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘spatstat.data’
There is a binary version available but the source version is later:
binary source needs_compilation
spatstat.data 1.1-0 1.1-1 FALSE
trying URL 'https://mirror.las.iastate.edu/CRAN/bin/windows/contrib/3.4/data.table_1.10.4-1.zip'
Content type 'application/zip' length 1577319 bytes (1.5 MB)
downloaded 1.5 MB
trying URL 'https://mirror.las.iastate.edu/CRAN/bin/windows/contrib/3.4/rgdal_1.2-13.zip'
Content type 'application/zip' length 30475771 bytes (29.1 MB)
downloaded 29.1 MB
trying URL 'https://mirror.las.iastate.edu/CRAN/bin/windows/contrib/3.4/spatstat_1.53-2.zip'
Content type 'application/zip' length 14521163 bytes (13.8 MB)
downloaded 13.8 MB
package ‘data.table’ successfully unpacked and MD5 sums checked
package ‘rgdal’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘rgdal’
package ‘spatstat’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘spatstat’
The downloaded binary packages are in
C:\Users\Patrick\AppData\Local\Temp\RtmpeaKi0Y\downloaded_packages
installing the source package ‘spatstat.data’
trying URL 'https://mirror.las.iastate.edu/CRAN/src/contrib/spatstat.data_1.1-1.tar.gz'
Content type 'application/x-gzip' length 2837063 bytes (2.7 MB)
downloaded 2.7 MB
* installing *source* package 'spatstat.data' ...
** package 'spatstat.data' successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
*** arch - x64
* DONE (spatstat.data)
The downloaded source packages are in
‘C:\Users\Patrick\AppData\Local\Temp\RtmpeaKi0Y\downloaded_packages’
> library(rgdal)
Error in library(rgdal) : there is no package called ‘rgdal’
> library(spatstat)
Error in library(spatstat) : there is no package called ‘spatstat’
You can find the directory that contains your installed packages with
.libPaths()
Which should give you something like:
"/Library/Frameworks/R.framework/Versions/3.3/Resources/library"
If you see rgdal or spatstat there I would delete them and then try installing again.

Resources