Unable to install ggplot2

Hello, I am a newbie at R and have been trying to install package ggplot2. Based on other answers I installed the package tidyverse as well. However I keep getting the following error:

Error in system2(if (nzchar(arch)) file.path(R.home(), "bin", arch, "Rterm.exe") else file.path(R.home("bin"), :
'"C:/PROGRA~1/R/R-4.0.3/bin/i386/Rterm.exe"' not found

  • removing 'C:/Users/shiny/OneDrive/Documents/R/win-library/4.0/ggplot2'
    Warning in install.packages :
    installation of package ‘ggplot2’ had non-zero exit status

Can you post the complete message you get? You might be omitting something relevant.

From what you have posted I can see a potential issue, your package library is in a could synced folder, this brings installation problems very often, try setting your package library in a non synced folder.

This is the full error msg:

*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
Error in system2(if (nzchar(arch)) file.path(R.home(), "bin", arch, "Rterm.exe") else file.path(R.home("bin"), :
'"C:/PROGRA~1/R/R-4.0.3/bin/i386/Rterm.exe"' not found

  • removing 'C:/Users/shiny/OneDrive/Documents/R/win-library/4.0/ggplot2'

The downloaded source packages are in
'C:\Users\shiny\AppData\Local\Temp\RtmpGg7tPl\downloaded_packages'

<U+2714> Package 'ggplot2' successfully installed.
Warning message:
In utils::install.packages("ggplot2", repos = "https://cran.rstudio.com/") :
installation of package 'ggplot2' had non-zero exit status

I moved my package to a non-synced folder. However I'm still getting the above error.

I think you are still not showing the complete output message you get, please post the whole thing, not just what you consider to be the error message

> install.packages("ggplot2")
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/shiny/OneDrive/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)

  There is a binary version available but the source version is later:
        binary source needs_compilation
ggplot2  3.3.2  3.3.3             FALSE

installing the source package ‘ggplot2’

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

* installing *source* package 'ggplot2' ...
** package 'ggplot2' successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare 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_eval                                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  
    bidirection                             html  
    binned_scale                            html  
    borders                                 html  
    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  
    element_render                          html  
    expand_limits                           html  
    expansion                               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  
    geom_density_2d                         html  
    geom_dotplot                            html  
    geom_errorbarh                          html  
    geom_function                           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  
    geom_qq                                 html  
    geom_quantile                           html  
    geom_ribbon                             html  
    geom_rug                                html  
    geom_segment                            html  
    geom_smooth                             html  
    geom_spoke                              html  
    geom_text                               html  
    geom_tile                               html  
    geom_violin                             html  
    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_axis                              html  
    guide_bins                              html  
    guide_colourbar                         html  
    guide_coloursteps                       html  
    guide_legend                            html  
    guide_none                              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  
    register_theme_elements                 html  
    remove_missing                          html  
    render_axes                             html  
    render_strips                           html  
    resolution                              html  
    scale_alpha                             html  
    scale_binned                            html  
    scale_brewer                            html  
    scale_colour_continuous                 html  
    scale_colour_discrete                   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_steps                             html  
    scale_type                              html  
    scale_viridis                           html  
    seals                                   html  
    sec_axis                                html  
    set_last_plot                           html  
    should_stop                             html  
    standardise_aes_names                   html  
    stat_ecdf                               html  
    stat_ellipse                            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  
    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
** testing if installed package can be loaded from temporary location
*** arch - i386
Error in system2(if (nzchar(arch)) file.path(R.home(), "bin", arch, "Rterm.exe") else file.path(R.home("bin"),  : 
  '"C:/PROGRA~1/R/R-4.0.3/bin/i386/Rterm.exe"' not found
* removing 'C:/Users/shiny/OneDrive/Documents/R/win-library/4.0/ggplot2'
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\shiny\AppData\Local\Temp\Rtmp4CGVHn\downloaded_packages’

If you are not using the most recent version of R, 4.0.3, I suggest you upgrade to that and then try installing ggplot2.

You are still using a cloud synced folder for your package library

You are missing the Rtools compiler or you haven't correctly configured

Do you have a particular reason for using the 32-bit version of R?

though the folder is under onedrive, it is unsynced.
i did install the rtools separately. And i have installed the 64-bit version only.

The error messages you are showing indicate otherwise so you might want to double-check your setup.

I'll try installing everything again.

it worked after re-installing everything in a new folder. Thank you so much for your help :slight_smile:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.