This can happens if save an object with an environment part of a package, e.g.
$ R --quiet --vanilla > fcn <- Matrix::Matrix > environment(fcn) <environment: namespace:Matrix> > quit("yes") # saves the workspace in an .RData file # Loading the .RData file at startup triggers 'Matrix' to be loaded $ R --quiet --no-init-file -e "loadedNamespaces()" > loadedNamespaces() [1] "compiler" "Matrix" "graphics" "utils" "grDevices" "stats" [7] "datasets" "grid" "methods" "base" "lattice" > > Also, if you have saved S4 objects (e.g. x <- Matrix::Matrix(0, 3, 2)), they will trigger their corresponding packages to be loaded when "used" (e.g. print():ed) but not before. Not saying it explains all of OPs packages - just wanted to say the content of .RData may trigger packages being loaded. /Henrik On Thu, Oct 22, 2020 at 7:54 PM Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote: > > Can you be more specific about what conditions cause R to automatically load > a package when a .RData file is loaded? My experience has actually been the > opposite. > > On October 22, 2020 6:13:11 PM PDT, Henrik Bengtsson > <henrik.bengts...@gmail.com> wrote: > >As Jeff says, it might be that you have a ~/.Rprofile file with > >instructions to load packages when R starts. It could also be that > >you have a .RData file, which is saved if you answer yes to: > > > >> Save workspace image? [y/n/c]: y > > > >when you quit R. If this file exists, then R loads it and all the > >objects you had when you saved it. If there are objects associated > >with packages, then that will cause those packages to be loaded when R > >starts. To avoid this, you need to move or delete the .RData file. > > > >You can use: > > > >> startup::startup(debug = TRUE, dryrun = TRUE) > > > >to get detailed information on what happens when R starts, e.g. if you > >have a .Rprofile file and an .RData file. That might help you to > >track down what's going on. The 'startup' package is on CRAN. > > > >I don't know of an easy way to restart RGui or RStudio Console in > >vanilla mode, similarly how you can start R at the terminal with 'R > >--vanilla'. > > > >/Henrik > > > >On Thu, Oct 22, 2020 at 4:14 PM Jeff Newmiller > ><jdnew...@dcn.davis.ca.us> wrote: > >> > >> Have you looked into your .Rprofile file? Loading packages is not > >something R normally does without your telling it to do so, but many > >people forget that they have done so. > >> > >> On October 22, 2020 3:47:04 PM PDT, Michael L Friendly > ><frien...@yorku.ca> wrote: > >> >[env: Windows, R 3.6.6] > >> > > >> >When I start R from the R Gui icon or from RStudio, I get a large > >> >number of packages loaded via a namespace. Not entirely clear where > >> >these come from. > >> > > >> >As a result, I often run into problems updating packages because > >> >something is already loaded. How can start a new gui session with > >> >minimal packages loaded? > >> > > >> >> sessionInfo() > >> >R version 3.6.3 (2020-02-29) > >> >Platform: x86_64-w64-mingw32/x64 (64-bit) > >> >Running under: Windows 7 x64 (build 7601) Service Pack 1 > >> > > >> >Matrix products: default > >> > > >> >locale: > >> >[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United > >> >States.1252 > >> >[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C > >> > > >> >[5] LC_TIME=English_United States.1252 > >> > > >> >attached base packages: > >> >[1] stats graphics grDevices utils datasets methods base > >> > > >> > > >> >loaded via a namespace (and not attached): > >> >[1] statmod_1.4.34 xfun_0.18 tidyselect_1.1.0 > >reshape2_1.4.4 > >> >purrr_0.3.4 mitools_2.4 > >> >[7] splines_3.6.3 lattice_0.20-41 coefplot_1.2.6 carData_3.0-4 > >> >colorspace_1.4-1 vctrs_0.3.4 > >> >[13] generics_0.0.2 htmltools_0.5.0 yaml_2.2.1 > >survival_3.2-7 > >> > rlang_0.4.7 pillar_1.4.6 > >> >[19] nloptr_1.2.2.2 glue_1.4.2 DBI_1.1.0 > >lifecycle_0.2.0 > >> > plyr_1.8.6 stringr_1.4.0 > >> >[25] effects_4.2-0 munsell_0.5.0 gtable_0.3.0 > >evaluate_0.14 > >> > knitr_1.30 fansi_0.4.1 > >> >[31] Rcpp_1.0.5 scales_1.1.1 useful_1.2.6 fs_1.4.2 > >> > lme4_1.1-23 packrat_0.5.0 > >> >[37] ggplot2_3.3.2 digest_0.6.25 stringi_1.4.6 > >insight_0.9.6 > >> > dplyr_1.0.2 survey_4.0 > >> >[43] grid_3.6.3 cli_2.1.0 tools_3.6.3 magrittr_1.5 > >> > tibble_3.0.4 crayon_1.3.4 > >> >[49] pkgconfig_2.0.3 ellipsis_0.3.1 MASS_7.3-53 > >Matrix_1.2-18 > >> > reprex_0.3.0 assertthat_0.2.1 > >> >[55] minqa_1.2.4 rmarkdown_2.4 rstudioapi_0.11 R6_2.4.1 > >> > boot_1.3-25 nnet_7.3-14 > >> >[61] nlme_3.1-149 compiler_3.6.3 > >> >> > >> > > >> >Michael Friendly Email: friendly AT yorku DOT ca > >> >Professor, Psychology Dept. & Former Chair, ASA Statistical Graphics > >> >Section > >> >York University Voice: 416 736-2100 x66249 > >> >4700 Keele Street Web: http://www.datavis.ca | @datavisFriendly > >> >Toronto, ONT M3J 1P3 CANADA > >> > > >> >______________________________________________ > >> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> >https://stat.ethz.ch/mailman/listinfo/r-help > >> >PLEASE do read the posting guide > >> >http://www.R-project.org/posting-guide.html > >> >and provide commented, minimal, self-contained, reproducible code. > >> > >> -- > >> Sent from my phone. Please excuse my brevity. > >> > >> ______________________________________________ > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide > >http://www.R-project.org/posting-guide.html > >> and provide commented, minimal, self-contained, reproducible code. > > -- > Sent from my phone. Please excuse my brevity. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.