Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mokymai/bio
:heavy_check_mark: Automated management of R and RStudio for my courses at Vinlius University (R package)
https://github.com/mokymai/bio
convenience-functions r rstudio-settings shortcut-keys
Last synced: 3 months ago
JSON representation
:heavy_check_mark: Automated management of R and RStudio for my courses at Vinlius University (R package)
- Host: GitHub
- URL: https://github.com/mokymai/bio
- Owner: mokymai
- License: other
- Created: 2020-01-16T18:08:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-31T17:26:11.000Z (3 months ago)
- Last Synced: 2024-08-01T20:23:57.019Z (3 months ago)
- Topics: convenience-functions, r, rstudio-settings, shortcut-keys
- Language: R
- Homepage: https://mokymai.github.io/bio
- Size: 4.77 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - mokymai/bio - :heavy_check_mark: Automated management of R and RStudio for my courses at Vinlius University (R package) (R)
README
---
title: "Package **_bio_**"
output: github_document
---```{r README-0, include=FALSE}
options(bio.local_list = TRUE)options(
repos = "https://cran.rstudio.com/",
pkgType = "both",
install.packages.check.source = "yes",
install.packages.compile.from.source = "always"
)Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS = "true")
```[![GitHub version](https://img.shields.io/badge/GitHub-`r packageVersion("bio")`-brightgreen.svg)](https://github.com/mokymai/bio)
[![R-CMD-check](https://github.com/mokymai/bio/workflows/R-CMD-check/badge.svg)](https://github.com/mokymai/bio/actions)
[![Updated-on](https://img.shields.io/badge/Updated%20on-`r gsub('-', '--', Sys.Date())`-yellowgreen.svg)](/commits/master)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![R-CMD-check](https://github.com/mokymai/bio/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mokymai/bio/actions/workflows/R-CMD-check.yaml)Convenience functions to facilitate installation and management of required resources for course unit __*Biostatistics*__ (*BS-2023*).
This package is intended to be used with RStudio 2024.04 or newer
and R 4.4.0 or newer.Functions may not work correctly with the previous versions of RStudio and R.
Bug reports and your feedback are welcome at https://github.com/mokymai/bio/issues.
In the report, indicate what operating system you are using.# Install
To install this package from CRAN-like repository, use code (recommended):
```{r README-1, eval=FALSE}
repos <- c("https://mokymai.github.io/download/", getOption("repos"))
install.packages("bio", repos = repos)
```Install form GitHub
To install this package from GitHub:
```{r README-2, eval=FALSE}
if (!require(remotes)) install.packages("remotes")
remotes::install_github("mokymai/bio", dependencies = TRUE)
```Note: installation from *GitHub* requires *RTools* on *Windows*.
# Examples
## Check information about OS and user
Check information about operating system (OS) and R-related user information.
```{r README-6, paged.print=FALSE, eval=FALSE}
bio::check_user_info()
## Operating system Windows 10 x64 (build 19044)
## Platform x86_64-w64-mingw32/x64 (64-bit)
## LOGNAME
## USERNAME User
## USERPROFILE C:/Users/User
## HOME C:/Users/User
## R_USER C:/Users/User
## R_HOME C:/PROGRA~1/R/R-4.2.2
## R_LIBS_USER C:/Users/User/AppData/Local/R/win-library/4.2
```## Check information about programs
Check versions of presence of installed R-related and other programs.
Options:- `"main"`{.r} (default) -- checks for "R", "RStudio", "Quarto", and "Rtools" ("Windows" only) or "R Build Tools" (non-"Windows" only).
- `"all"`{.r} -- additionally checks for presence of "XQuartz" ("Mac" only), "Git" (all systems), and (sometimes) "Meld".
```{r README-7a, eval=FALSE}
bio::check_installed_programs()
## ✔ Program R (4.3.1) is installed (recommended >= 4.3.1).
## ✖ Program RStudio is not installed or is not running.
## ✔ Tool Quarto (1.4.268) is installed (recommended >= 1.3.336).
## ✔ Tool Rtools is installed.
``````{r README-7b, eval=FALSE}
bio::check_installed_programs("all")
## ✔ Program R (4.3.1) is installed (recommended >= 4.2.2, available 4.3.1).
## ✔ Program RStudio (2023.6.1.524) is installed (recommended >= 2023.3.0, available 2023.6.1.524).
## ✔ Tool Quarto (1.4.268) is installed (recommended >= 1.3.336).
## ✔ Tool Rtools is installed.
## ✔ Program Git is installed.
## ✔ Program Meld is installed.
```## Check installation status of "R" packages
It is recommended to check installation status and version of required packages by name:
```{r README-8-by-name, eval=FALSE, paged.print=FALSE}
bio::check_packages_by_name(c("bio", "remotes", "tidyverse"))
## ✔ Minimal required versions of all 3 packages are already installed.
```There is a less recommended way (due to lower transparency) to check installation status of packages by topic.
By default, only missing packages or packages with lower versions than recommended are displayed.
Currently available lists can be returned by function `bio::get_pkg_lists_local()`{.r}.Details
```{r echo=FALSE, results='asis'}
res <- paste0(
"\n",
paste0("- `'", bio:::get_pkg_lists_local(), "'`", collapse = "\n"),
"\n\n"
)
cat(res)
``````{r README-8a, eval=FALSE, paged.print=FALSE}
bio::check_packages_by_topic("mini")
## ℹ Reading list 'mini'
## ✔ Minimal required versions of all 19 packages (from list 'mini') are already installed.
``````{r README-8b, eval=FALSE, paged.print=FALSE}
bio::check_packages_by_topic("mini", include = "newer_on_cran")
## ℹ Reading list 'mini'
## ✔ Minimal required versions of all 19 packages (from list 'mini') are already installed.
## ℹ Note: 1 package has newer version on CRAN.
```## Update packages
These are the convenience functions to update certain R packages.
The functions restart R before installation if used in RStudio.Update package **bio**.
```{r README-3a, eval=FALSE}
bio::update_pkg_bio()
```Check if there are updates for **bio** or its dependency packages.
```{r README-3b, eval=FALSE, paged.print=FALSE}
bio::check_updates_pkg_bio()
## ℹ Analyzing dependencies of package bio
##
## [... truncated ...]
##
## ✔ Minimal required versions of all 26 packages (from list 'bio') are already installed.
```Update package **snippets**.
```{r README-4, eval=FALSE}
bio::update_pkg_snippets()
```## RStudio settings and user preferences
> Make sure that you understand what you are doing when you try using the functions
that reset RStudio key bindings (shortcut keys), settings or snippets.
> **You may loose _all_ your previous settings.**### Dictionaries
This function downloads or updates **hunspell** spelling checking dictionaries dictionaries (including Lithuanian) that can be used by RStudio or by tools from **wellspell.addin** package.
```{r eval=FALSE}
bio::rstudio_install_spellcheck_dictionaries()
```Install improved Lithuanian dictionary.
```{r eval=FALSE}
bio::rstudio_install_spellcheck_dictionary_lt()
## ✔ lt_LT dictionary installed.
## 'C:/Users/ViG/AppData/Roaming/RStudio/dictionaries/languages-system/lt_LT.dic'
```### Shortcut keys
This function changes shortcut keys in RStudio.
Run function without arguments to see the available options.
```{r README-9a, eval=FALSE, error=TRUE}
bio::rstudio_reset_keybindings()
## Error: The value of argument 'to' is missing.
## Possible options: 'bio-default', 'rstudio-default'.
```Options:
- `"bio-default"`{.r} -- shortcut keys recommended for course BS-2023.
- `"rstudio-default"`{.r} -- RStudio defaults.```{r README-9b, eval=FALSE}
bio::rstudio_reset_keybindings(to = "bio-default")
## ✔ Back up copy of shortcut keys was created in 'C:/Users/User/.R/_backup/keybindings/'
## ✔ Shortcut keys were reset to bio-default.
```: **Table 1.** Some examples of shortcut keys set with option `"bio-default"`{.r}.
| Shortcut | Action |
|--------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| Shift+Alt+S | Insert inline LaTeX equation (*R Markdown*). |
| Shift+Alt+A | Use "Tidyverse" style on selected lines of R code. Package **styler** must be installed (*R code*). |
| Ctrl+Shift+D | Duplicate selected text. |
| Ctrl+Shift+Alt+S | Check spelling in selected text. Package [**wellspell.addin**][wsa] must be installed. |
| Ctrl+Shift+Alt+P | Align parts of selected lines at a custom pattern. |
| Ctrl+Shift+] | Change heading one level down (*R Markdown*) **[!]**. |
| Ctrl+Shift+[ | Change heading one level up or remove heading (*R Markdown*) **[!]**. |
| Ctrl+Shift+; | Insert lower opening quotes `„`. |
| Ctrl+Shift+' | Insert upper closing quotes `“`. |
| Ctrl+E | **Insert/Enclose with R code block** (*R Markdown*) **[!]** . |
| Ctrl+Alt+T | Insert inline code highlighted as R code (R Markdown). |
| Ctrl+Alt+NumPad8 | Insert operator `%*%` (*R code*). |
| Ctrl+Alt+NumPad7 | Insert operator `%in%` (*R code*). |
| Ctrl+Alt+D | Document R package (that you are building). |[wsa]: https://github.com/nevrome/wellspell.addin
More on [Customizing Keyboard Shortcuts](https://support.rstudio.com/hc/en-us/articles/206382178-Customizing-Keyboard-Shortcuts){target="_blank"} in RStudio.
### RStudio settings
This function resets RStudio user preferences and settings.
Run function without arguments to see the available options.
```{r README-10a, eval=FALSE, error=TRUE}
bio::rstudio_reset_user_settings()
#> Error: The value of argument 'to' is missing.
#> Possible choices: 'bio-default', 'bio-dark-blue', 'bio-black', 'rstudio-default'.
```The options:
- `"bio-default"`{.r} -- recommended `bio` settings (and light theme "Textmate (default)");
- `"bio-dark-blue"`{.r} -- recommended `bio` settings (and dark blue theme "Cobalt");
- `"bio-black"`{.r} -- recommended `bio` settings (and black theme "Chaos");
- `"rstudio-default"`{.r} -- default RStudio settings.```{r README-10b, eval=FALSE}
bio::rstudio_reset_user_settings(to = "bio-default")
```To check, how your settings differ from the defaults in a certain list, use:
```{r README-10c, eval=FALSE}
bio::rstudio_compare_user_settings(to = "bio-default")
## ℹ Show differences between current and bio-default setting lists.
## ✔ No differences
```The settings that are not in the list will not be displayed.
Available options of `to` are "bio-default" and "rstudio-default".### Snippets
The function replaces current R code and R Markdown snippets with those in package "snippets".
```{r, eval=FALSE}
snippets::install_snippets_from_package("snippets", backup = TRUE)
## ✔ File with markdown snippets was updated:
## 'C:/Users/User/AppData/Roaming/RStudio/snippets/markdown.snippets'
## ✔ File with r snippets was updated:
## 'C:/Users/User/AppData/Roaming/RStudio/snippets/r.snippets'
##
## ℹ You will be able to use the snippets after RStudio is closed and reopened.
```More information on
[Code Snippets](https://support.rstudio.com/hc/en-us/articles/204463668-Code-Snippets){target="_blank"} in RStudio and on package
[**snippets**](https://gegznav.github.io/snippets/){target="_blank"}.### Restart R and RStudio
If you want to see the effect of changed settings, you should reload RStudio.
You may use this function, which reloads RStudio without closing it:```{r, eval=FALSE}
bio::restart_rstudio()
```
However, in some cases it is recommended to close and reopen RStudio.Next, to restart R session without closing RStudio, use:
```{r, eval=FALSE}
bio::restart_r()
```
Useful to apply before trying to install R packages.