Skip to content

Commit

Permalink
Added code for vignette-03
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-arino committed Dec 27, 2023
1 parent 5d32831 commit d851039
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
32 changes: 32 additions & 0 deletions CODE/vignette-03-installing-using-packages.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Example code for Vignette 3: Installing and Using Packages

paste(nrow(available.packages()),
"packages on CRAN on",
Sys.Date())

# Load several libraries
required_packages = c("ggplot2", "dplyr")
for (p in required_packages) {
library(p, character.only = TRUE)
}

# Friendly way of loading libraries: if present, load, if not,
# install and load
required_packages = c("ggplot2", "dplyr")
for (p in required_packages) {
if (!require(p, character.only = TRUE)) {
install.packages(p)
library(p, character.only = TRUE)
}
}


update.packages(ask = FALSE, checkBuilt = TRUE, Ncpus = 6)

# From https://www.r-bloggers.com/2014/11/update-all-user-installed-r-packages-again/
install.packages(
lib = lib <- .libPaths()[1],
pkgs = as.data.frame(installed.packages(lib),
stringsAsFactors=FALSE)$Package,
type = 'source'
)
14 changes: 13 additions & 1 deletion SLIDES/vignette-03-installing-using-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ Use the command `install.packages()`

---

# From GitHub

Some packages are only on GitHub; others have their latest (testing) version on GitHub and a stable version on CRAN

Need to use the `devtools` or `remotes` packages (maybe prefer `devtools`)

You can also use the package [githubinstall](https://cran.r-project.org/web/packages/githubinstall/vignettes/githubinstall.html)

---

<!-- _backgroundImage: "linear-gradient(to bottom, red, black)" -->
<a id="sec:loading"></a>
# <!--fit-->Loading a package
Expand Down Expand Up @@ -215,4 +225,6 @@ Packages are stored by default in your home folder under the current major versi
~/R/x86_64-pc-linux-gnu-library/4.3/
```

When the major version changes, you therefore need to do something with all your current packages...
When the major version changes, you therefore need to do something with all your current packages..

There is no planned mechanisms for doing this

0 comments on commit d851039

Please sign in to comment.