Misc

Misc

  • Windows

    Shortcut Description
    Ctrl + Tab Change application
    Ctrl + ~ Change window within an application
  • Browser

    Action Shortcut
    To Address Bar Ctrl + L
    Open a new window Ctrl + n
    Open a new window in Incognito mode Ctrl + Shift + n
    Open a new tab, and jump to it Ctrl + t
    Reopen previously closed tabs in the order they were closed Ctrl + Shift + t
    Jump to the next open tab Ctrl + Tab or Ctrl + PgDn
    Jump to the previous open tab Ctrl + Shift + Tab or Ctrl + PgUp
    Jump to a specific tab Ctrl + 1 through Ctrl + 8
    Jump to the rightmost tab Ctrl + 9
    Open your home page in the current tab Alt + Home
    Open the previous page from your browsing history in the current tab Alt + Left arrow
    Open the next page from your browsing history in the current tab Alt + Right arrow
    Close the current tab Ctrl + w or Ctrl + F4
    Close the current window Ctrl + Shift + w or Alt + F4
    Minimize the current window Alt + Space then n
    Maximize the current window Alt + Space then x
    Quit Google Chrome Alt + f then x
    Move tabs right or left Ctrl + Shift + PgUp or Ctrl + Shift + PgDn

R

  • Search for R packages

  • R-devel (>= 4.4.0) gained a command-line option to adjust the connections limit (previous limit was 128 parallel workers)

    $ R
    > parallelly::availableConnections()
    [1] 128
    
    $ R --max-connections=512
    > parallelly::availableConnections()
    [1] 512
  • Get installed package names, versions, environment, source (article)

    > package_names <- installed.packages()[, 1]
    > package_data <- lapply(
    +     package_names,
    +     utils::packageDescription,
    +     fields = c("Package", "Version", "Built", "Repository")
    + ) |>
    +     lapply(as, Class = "list") |>
    +     lapply(setNames, c("Package", "Version", "Environment", "Source")) |>
    +     dplyr::bind_rows()
    • Environment has OS info, R version, and date installed.
  • Java Dependent Packages

    • {rJavaEnv} - Aims to assist users of all {rJava}-dependent packages by providing functions to quickly install the required Java version and set environment variables.
      • It downloads non-installer archives of Java, extracts them to a cache folder, and links them in the current project or working directory. This way, rJavaEnv does not contaminate the user’s machine with unnecessary installations and configurations.

Hackathon Criteria

Update R

  • Misc
    • https://www.r-project.org/

    • {rig} - r version management system

    • update.packages(checkBuilt = TRUE, ask = FALSE) is supposed to search for packages in other R versions and update them in the new R version, but I haven’t tried it, yet.

    • Install the newest stable version to check it out

      rig add next
      R-next
      • R-<ver> runs a R version without it being the default
    • Errors when compiling from source may require installing libraries and they’ll supply code to install via “pacman”

      • Open Start >> scroll down to RTools40 >> RTools Bash
      • Paste pacman code and hit enter to install
    • Problem packages in the past

      • {brms} dependency, {igraph}, didn’t have a binary on CRAN and wouldn’t compile from source even with correct libraries installed.
        • Sol’n: install.packages("igraph", repos = 'https://igraph.r-universe.dev')
          • installs dev version from r-universe
      • Some {easystats} packages had gave {pak} some problems. No difficulties using install.packages with default repo or if they had a r-universe repo though.
  • Steps
    1. Copy user installed packages in current R version

      • In R:

        squirrel <- names(installed.packages(priority = "NA")[, 1]) # user installed packages
        readr::write_rds(squirrel, "packages.rds")
        • Then, close RStudio
    2. RTools: Check to see if you have the latest because you’ll need it to compile some of newest versions of packages.

      • Your rtools folder has the version in it’s folder name.
      • rtools website has the latest version and an .exe to download
      • rig add rtools43 will install the RTools for R 4.3 or you can specify any version
      • rig add rtools will install all RTools versions for all R versions that are installed.
    3. Check/Update rig version

      • In powershell: rig --version
      • Check current rig release: link
      • Download and install if your version isn’t current
    4. Install new version of R

      • Close R if not already closed
      • rig add release installs the latest version of R.
      • rig default <new_r_version> sets that version as the default
    5. Add R and RTools to path

      • Right-click Windows >> System >> (right panel) Advanced System Settings >> Environment Variables >> Under User Variables, highlight Path, click Edit >> Click Add
        • R: Add path to directory with all the RScript, R exe, etc. e.g. “C:\Program Files\R\R-4.2.3\bin\x64”
        • RTools: e.g. “C:\rtools43\usr\bin”
    6. Open R and confirm new version

      • If RStudio
        • The setting of the new version to the “default” version of R in rig should result in RStudio loading the new version.
        • If not, Tools >> Global Options >> General
          • Under “R version”, click “change” button; choose new R version
          • Quit session and restart RStudio
    7. Install “high maintenance” packages

      • I’ve had issues with {pak} installing packages that need to be compiled. Maybe be worth trying {pak} first to see if they’ve fixed it.
      • {cmdstanr} doesn’t live on CRAN, so you have to use: install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
        • Check for latest cmdstan version
          • After loading the package, library(cmdstanr) , it should run a check on your cmdstan version and tell you if there’s a newer version.
          • To update, first check toolchain: check_cmdstan_toolchain()
            • Might tell you to update RTools or that you need some C++ library added
          • Fix C++ toolchain with check_cmdstan_toolchain(fix = TRUE)
          • Update cmdstan: install_cmdstan()
          • May need to install {rstudioapi} and run rstudioapi::restartSession() (programmatically) or just ctrl + shift + f10 so that this package can be used as a dependency for other packages that need to be installed.
      • {rstanarm}: install.packages("rstanarm")
    8. Install other packages

      moose <- readRDS("packages.rds")
      moose <- moose[!moose %in% c("cmdstanr", "rstanarm", "ebtools", "translations", "<RStudio add-ins>")]
      
      # Next time, add a try/catch? or maybe purrr::safely, so that it continues through errors. Also, need to log pkgs that do error.
      for (i in seq_len(length(moose))) {
        print(moose[i])
        pak::pkg_install(moose[i])
      }
      
      fs::file_delete("packages.rds")
      • {ebtools} is my personal helper package.
      • {translations} is a system package that shouldn’t have been included when I saved the packages from previous version, but was when I recently updated. Might not be necessary to include it in the excuded packages in the future.
    9. Check for updates of RStudio (link)

      • Current version under Help >> About Rstudio
      • Possible to check for updates under Help >> Check for Updates, but that’s failed me before.