# This script is intented to test whether the basic
# requirements for an R-installation is met, prior
# to taking part in the R4PHD courses.
### Operating system
<- Sys.info()[['sysname']]
sys_name <- Sys.info()[['release']]
sys_version <- Sys.info()[['machine']]
sys_machine
if (sys_name %in% c("Linux", "MacOS", "Windows")) {
print(paste0("[OK] Your operating system is ", sys_name, " (version ", sys_version,")"))
else {
} print(paste0("[WARNING] Your operating system is reported as '", sys_name, "'. 'Linux', MacOS' or 'Windows' was expected."))
}
### CPU architecture
if (sys_machine %in% c("x86_64", "amd64", "arm64", "x86-64")) {
print("[OK] You computer has a 64 bit CPU")
else if (sys_machine %in% c("i386", "i586", "i686")) {
} print("[WARNING] You computer has an older 32 bit CPU")
else {
} print(paste0("[WARNING] You computer is reported as ",sys_machine," ... not what was expected."))
}
### R version
<- R.Version()[['major']]
r_version_major <- R.Version()[['version.string']]
r_version_string
if (r_version_major >= "4") {
print(paste0("[OK] R installation is: ", r_version_string))
else {
} print(paste0("[WARNING] An R version 4.x.x is recommended. You installation is ", r_version_string))
}
### RStudio version
<- rstudioapi::versionInfo()$mode
rstudio_type <- rstudioapi::versionInfo()$version
rstudio_version
if (rstudio_type == "desktop") {
print("[OK] The RStudio installation is 'desktop'")
else {
} print(paste0("[WARNING] The RStudio installation is '", rstudio_type,"'. Version 'desktop' is recommended!"))
}
if (rstudio_version > "2023") {
print(paste0("[OK] The RStudio version is ",rstudio_version))
else {
} print(paste0("[WARNING] The RStudio version is ",rstudio_version, ". Version 2023+ was expected."))
}
<- .packages(all.available = TRUE)
all_installed_packages <- c("tidyverse", "here", "skimr", "gt", "gtExtras", "gtsummary", "patchwork", "naniar", "reprex", "ggstatsplot", "easystats", "vroom")
recommended_packages
for (p in recommended_packages) {
if (p %in% all_installed_packages) {
print(paste0("[OK] '", p, "' (package) is installed."))
else {
} print(paste0("[WARNING] '", p, "' (package) is NOT installed."))
} }
Check all is OK
Er alt på plads før dit R kursus?
1 Tjek din R installation
Under antagelse af, at du har en fungerende installation af R and RStudio, så gør følgende:
Vis mig hvordan
1. Først udfold call-out boksen herunder (‘Installations tjekker’)
2. Dernæst, kopier koden fra kode-feltet ved at klikke på clip-board ikonet i øverste, højre hjørne af feltet som kommer frem når musen er over
3. Luk for call-out boksen igen
Installations tjekker
4. Åben RStudio
5. Lav et nyt, tomt R script dokument via tastatus: CTRL-SHIFT-n eller menu: File / New File / R Script
6. Indsæt den kopierede kode i dokumentet
7. Eksekvér hele koden via tastatur: CTRL-SHIFT-s, eller menu: Code / Source eller med musen: klik ‘Source’ i øverste højre hjørne af tekst editor panelet.
8. Gennemlæs out i konsollen