# 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", "patchwork", "gt", "gtsummary", "ggstatsplot", "easystats", "rstatix", "naniar", "readr", "readxl", "vroom", "colourpicker", "colorspace")
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."))
}
}
print("The following packages are consider 'extra' - don't fret if they're not installed yet")
<- c("ggthemes", "gganimate", "ggiraph", "kableExtra", "gtExtras", "glue", "gapminder", "ggside")
extra_packages
for (p in extra_packages) {
if (p %in% all_installed_packages) {
print(paste0("[OK] '", p, "' (package) is installed."))
else {
} print(paste0("[NOTE] '", p, "' (package) is not installed."))
} }
Check all is ready for R4PHD course
Assuming you now have a working installation of R and RStudio, do the following:
First unfold the call-out box below (‘Installation checker’)
Next copy the code presented in the code listing by clicking the clip-board icon in the right hand corner of the code listing filed, which appears on mouse-over
Close the call-out box again
Open RStudio
Create a new, empty R Script by keyboard: CTRL-SHIFT-n or menu: File / New File / R Script
Paste the code into the empty document
Execute all the code by keyboard: CTRL-SHIFT-s, or menu: Code / Source or mouse: click ‘Source’ in the top-right hand corner of the text editor panel.
Examine the output in the Console
1 Problems?
Look at the output of the R script: Any [WARNING]
messages?
If any of the recommended packages are not installed, then go ahead and install them as described on the previous page ‘R package installation’.
Hvis du nu har en fungerende installation af R og RStudio, skal du gøre følgende:
Udfold først callout boksen nedenfor (‘Installationskontrol’)
Kopier derefter koden fra kodefeltet ved at klikke på udklipsholderikonet i højre hjørne af kodefeltet, som vises når musen er over feltet
Luk callout boksen igen
# 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", "patchwork", "gt", "gtsummary", "ggstatsplot", "easystats", "rstatix", "naniar", "readr", "readxl", "vroom", "colourpicker", "colorspace")
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."))
}
}
print("The following packages are consider 'extra' - don't fret if they're not installed yet")
<- c("ggthemes", "gganimate", "ggiraph", "kableExtra", "gtExtras", "glue", "gapminder", "ggside")
extra_packages
for (p in extra_packages) {
if (p %in% all_installed_packages) {
print(paste0("[OK] '", p, "' (package) is installed."))
else {
} print(paste0("[NOTE] '", p, "' (package) is not installed."))
} }
Åbn RStudio
Opret et nyt, tomt R-script med: CTRL-SHIFT-n eller menu: Files / New fil / R-script
Indsæt koden i det tomme dokument
Eksekvér al koden med: CTRL-SHIFT-s, eller menu: Code / Source eller mus: klik på ‘Source’ i øverste højre hjørne af tekstredigeringspanelet.
Inspicér output i konsollen
2 Problemer?
Se på outputtet af R-scriptet: Er der nogen [WARNING]
-meddelelser?
Hvis nogen af de anbefalede pakker ikke er installeret, så fortsæt og installer dem som beskrevet på den forrige side ‘R-pakkeinstallation’.