Error installing ggplot2 in R studio

I have a problem Installing ggplot2 I read many threads but none help me out. Appreciate your time and help!

Installing package into ‘\\xxx.local/shared/UsersMyDocs/alijanim/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)

  There is a binary version available but the source version is later:
        binary source needs_compilation
ggplot2  3.1.1  3.2.0             FALSE

installing the source package ‘ggplot2’

trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.2.0.tar.gz'
Content type 'application/x-gzip' length 3193995 bytes (3.0 MB)
downloaded 3.0 MB

'\\xxx.local\shared\UsersMyDocs\xxx\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
* installing *source* package 'ggplot2' ...
** package 'ggplot2' successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
  converting help for package 'ggplot2'
    finding HTML links ... done
    absoluteGrob                            html  
    add_theme                               html  
    aes                                     html  
    aes_                                    html  
    aes_all                                 html  
    aes_auto                                html  
    aes_colour_fill_alpha                   html  
    aes_group_order                         html  
    aes_linetype_size_shape                 html  
    aes_position                            html  
    annotate                                html  
    annotation_custom                       html  
    annotation_logticks                     html  
    annotation_map                          html  
    annotation_raster                       html  
    as.list.ggproto                         html  
    as_labeller                             html  
    autolayer                               html  
    autoplot                                html  
    benchplot                               html  
    borders                                 html  
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/borders.Rd:26: missing file link 'pathGrob'
    calc_element                            html  
    combine_vars                            html  
    continuous_scale                        html  
    coord_cartesian                         html  
    coord_fixed                             html  
    coord_flip                              html  
    coord_map                               html  
    coord_munch                             html  
    coord_polar                             html  
    coord_trans                             html  
    cut_interval                            html  
    diamonds                                html  
    discrete_scale                          html  
    draw_key                                html  
    economics                               html  
    element                                 html  
    element_grob                            html  
    expand_limits                           html  
    expand_scale                            html  
    facet_grid                              html  
    facet_null                              html  
    facet_wrap                              html  
    faithfuld                               html  
    find_panel                              html  
    fortify-multcomp                        html  
    fortify                                 html  
    fortify.lm                              html  
    fortify.map                             html  
    fortify.sp                              html  
    geom_abline                             html  
    geom_bar                                html  
    geom_bin2d                              html  
    geom_blank                              html  
    geom_boxplot                            html  
    geom_contour                            html  
    geom_count                              html  
    geom_density                            html  
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/geom_density.Rd:66: missing file link 'bw.nrd'
    geom_density_2d                         html  
    geom_dotplot                            html  
    geom_errorbarh                          html  
    geom_hex                                html  
    geom_histogram                          html  
    geom_jitter                             html  
    geom_linerange                          html  
    geom_map                                html  
    geom_path                               html  
    geom_point                              html  
    geom_polygon                            html  
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/geom_polygon.Rd:40: missing file link 'pathGrob'
    geom_qq                                 html  
    geom_quantile                           html  
    geom_ribbon                             html  
    geom_rug                                html  
    geom_segment                            html  
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/geom_segment.Rd:89: missing file link 'curveGrob'
    geom_smooth                             html  
    geom_spoke                              html  
    geom_text                               html  
    geom_tile                               html  
    geom_violin                             html  
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/geom_violin.Rd:77: missing file link 'bw.nrd'
    gg-add                                  html  
    gg_dep                                  html  
    ggplot                                  html  
    ggplot2-ggproto                         html  
    finding level-2 HTML links ... done

    ggplot2-package                         html  
    ggplotGrob                              html  
    ggplot_add                              html  
    ggplot_build                            html  
    ggplot_gtable                           html  
    ggproto                                 html  
    ggsave                                  html  
    ggsf                                    html  
    ggtheme                                 html  
    graphical-units                         html  
    guide-exts                              html  
    guide_colourbar                         html  
    guide_legend                            html  
    guides                                  html  
    hmisc                                   html  
    is.Coord                                html  
    is.facet                                html  
    is.ggplot                               html  
    is.rel                                  html  
    is.theme                                html  
    label_bquote                            html  
    labeller                                html  
    labellers                               html  
    labs                                    html  
    last_plot                               html  
    layer                                   html  
    layer_sf                                html  
    limits                                  html  
    lims                                    html  
    luv_colours                             html  
    map_data                                html  
    max_height                              html  
    mean_se                                 html  
    merge_element                           html  
    midwest                                 html  
    mpg                                     html  
    msleep                                  html  
    position_dodge                          html  
    position_identity                       html  
    position_jitter                         html  
    position_jitterdodge                    html  
    position_nudge                          html  
    position_stack                          html  
    presidential                            html  
    print.ggplot                            html  
    print.ggproto                           html  
    qplot                                   html  
    reexports                               html  
    remove_missing                          html  
    render_axes                             html  
    render_strips                           html  
    resolution                              html  
    scale_alpha                             html  
    scale_brewer                            html  
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/scale_brewer.Rd:37: missing file link 'brewer.pal'
    scale_colour_continuous                 html  
    scale_continuous                        html  
    scale_date                              html  
    scale_discrete                          html  
    scale_gradient                          html  
    scale_grey                              html  
    scale_hue                               html  
    scale_identity                          html  
    scale_linetype                          html  
    scale_manual                            html  
    scale_shape                             html  
    scale_size                              html  
    scale_type                              html  
    scale_viridis                           html  
    seals                                   html  
    sec_axis                                html  
    set_last_plot                           html  
    should_stop                             html  
    standardise_aes_names                   html  
    stat                                    html  
    stat_ecdf                               html  
    stat_ellipse                            html  
    stat_function                           html  
    stat_identity                           html  
    stat_sf_coordinates                     html  
    stat_summary                            html  
    stat_summary_2d                         html  
    stat_unique                             html  
    summarise_plot                          html  
    summary.ggplot                          html  
    theme                                   html  
    theme_get                               html  
    tidyeval                                html  
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/tidyeval.Rd:23: missing file link 'syms'
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/tidyeval.Rd:25: missing file link 'expr'
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/tidyeval.Rd:25: missing file link 'quo'
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/tidyeval.Rd:28: missing file link 'exprs'
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/tidyeval.Rd:29: missing file link 'quos'
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/tidyeval.Rd:31: missing file link 'enexpr'
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/tidyeval.Rd:31: missing file link 'enquo'
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/tidyeval.Rd:35: missing file link 'enexprs'
Rd warning: C:/Users/alijanim/AppData/Local/Temp/1/RtmpecGVZs/R.INSTALL28f827b728aa/ggplot2/man/tidyeval.Rd:35: missing file link 'enquos'
    transform_position                      html  
    translate_qplot_ggplot                  html  
    translate_qplot_lattice                 html  
    txhousing                               html  
    update_defaults                         html  
    update_labels                           html  
    vars                                    html  
    waiver                                  html  
    wrap_dims                               html  
    zeroGrob                                html  
*** copying figures
** building package indices
** installing vignettes
Warning in file(con, "w") :
  cannot open file '\\xxx.local/shared/UsersMyDocs/xxx/Documents/R/win-library/3.4/ggplot2/doc/index.html': No such file or directory
Error in file(con, "w") : cannot open the connection
ERROR: installing vignettes failed
* removing '\\xxx.local/shared/UsersMyDocs/xxx/Documents/R/win-library/3.4/ggplot2'
In R CMD INSTALL
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" CMD INSTALL -l "\\xxx.local\shared\UsersMyDocs\xxx\Documents\R\win-library\3.4" C:\Users\alijanim\AppData\Local\Temp\1\RtmpQhC2Vt/downloaded_packages/ggplot2_3.2.0.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\alijanim\AppData\Local\Temp\1\RtmpQhC2Vt\downloaded_packages’
> install.packages("vignettes")
Installing package into ‘\\xxx.local/shared/UsersMyDocs/alijanim/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘vignettes’ is not available (for R version 3.4.3)

There is no package "vignettes", that error means that the installer is not being able to install the vignettes of the ggplot2 package in that specific folder. Is your package library located in a network drive? that usually brings this kind of problems, try installing to a local folder instead.

Hi,
Everything is in my local folder. I have two folders, library like folder, in two locations:
C:\Program Files\R\R-3.4.3\library and \xxxlocal \shared\UsersMyDocs\users\Documents\R\win-library\3.4 and I am not sure if it causes an issue. When installed R studio both created.
The point is when I go to Packages->Install by default "install to Library" has been set to
\xxxlocal \shared\UsersMyDocs\users\Documents\R\win-library\3.4
Do you think there is problem with this?
I also uninstalled and installed R studio again bur the same error persisted.
Thanks a lot!

This path looks very unusual, try installing to the other folder (make sure to run RStudio as Administrator).

install.packages("ggplot2", lib = "C:/Program Files/R/R-3.4.3/library")

First of all it is complaining:

Warning in install.packages :
  'lib = "C:/Program Files/R/R-3.4.3/library"' is not writable

then I set that as working library.What it did was the thing that I copied in my first message and at the end again

** building package indices
** installing vignettes
Warning in file(con, "w") :
  cannot open file '\\xxx.local/shared/UsersMyDocs/alijanim/Documents/R/win-library/3.4/ggplot2/doc/index.html': No such file or directory
Error in file(con, "w") : cannot open the connection
ERROR: installing vignettes failed
* removing '\\xxx.local/shared/UsersMyDocs/alijanim/Documents/R/win-library/3.4/ggplot2'
In R CMD INSTALL
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" CMD INSTALL -l "\\xxx.local\shared\UsersMyDocs\alijanim\Documents\R\win-library\3.4" C:\Users\alijanim\AppData\Local\Temp\1\Rtmp6fYbJB/downloaded_packages/ggplot2_3.2.0.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\alijanim\AppData\Local\Temp\1\Rtmp6fYbJB\downloaded_packages’ 

I have no clue and both of those folders have packages inside which are NOT the same

Should copy all the content of

\xxxlocal \shared\UsersMyDocs\users\Documents\R\win-library\3.4

to

C:/Program Files/R/R-3.4.3/library

?
Here is the screenshot of Tools-> Global Options. I changed the default working directory to

 C:/Program Files/R/R-3.4.3/library

Again, are you running RStudio as administrator? this seems like a permissions issue.

I don't have administrator access. Yes, I will try again and let you know the following

install.packages("ggplot2", lib = "C:/Program Files/R/R-3.4.3/library")

Thanks a lot. I was able to install ggplot2 with administrator permission. Do you recommend me to copy all libraries from the unusual path

\xxxlocal \shared\UsersMyDocs\users\Documents\R\win-library\3.4

to

 C:/Program Files/R/R-3.4.3/library

or I can leave them in whatever location as they are.

Thank you for you time!

You just have to make sure to have write permissions in your library folder, which one you choose to work with depends on your workflow and personal preferences, in my case, I like to install packages system wide so I use "C:/Program Files/R/R-3.6.1/library"