Rate limited by GitHub when using remotes::install_github()

When you use remotes::install_github() too often in a short span of time, GitHub may rate limit you. This means you can’t use install the package you wanted without waiting for the rate limit to end. One way around this (and to prevent getting rate limited) is to simply clone the repo and use remotes::install_local()! To…

Continue Reading

Find out which function is being used in R

Today I learned of the utils::getAnywhere() function in R, which I discovered when looking for a way to determine which function is going to be used when two attached packages have the same function name. I knew of base::search() which provides the search path used by R to look for objects (remember that everything in…

Continue Reading

Prevent download errors in R by increasing the timeout

If you find yourself getting a "Timeout of 60 seconds was reached" warning from download.file that’s preventing you from installing a package, you can increase the timeout in R by using options(). For example, when I was trying to run the following command: SeuratData::InstallData('ifnb') trying URL 'http://seurat.nygenome.org/src/contrib/ifnb.SeuratData_3.1.0.tar.gz' Content type 'application/octet-stream' length 413266233 bytes (394.1 MB)…

Continue Reading

Check when install.packages fails in R

I recently found out that when install.packages() fails, it only returns a warning and not an error, i.e., the exit code is 0. R -q -e 'install.packages("thisdoesnotexist!!!")' > install.packages("thisdoesnotexist!!!") Installing package into ‘/home/dtang/R/x86_64-pc-linux-gnu-library/4.3’ (as ‘lib’ is unspecified) Warning message: package ‘thisdoesnotexist!!!’ is not available for this version of R A version of this package for…

Continue Reading

Reading a list of files into a single R data frame

I had been using map_dfr from the purrr package to load multiple files into one single data frame. But this function has been superseded with the following explanation: The functions were superseded in purrr 1.0.0 because their names suggest they work like _lgl(), _int(), etc which require length 1 outputs, but actually they return results…

Continue Reading

Reading irregular data into R

Some bioinformatics tools output files that are visually nice and are meant for manual inspection. This practice of generating visually nice output (and/or) Excel files may be rooted in how bioinformaticians and biologists used to work with each other; give the bioinformatician/s some data to analyse and they will generate output that will be manually…

Continue Reading

R function for calculating confusion matrix rates

Last updated: 2023/03/10 I often forget the names and aliases (and how to calculate them) of confusion matrix rates and have to look them up. Finally, I had enough and was looking for a single function that could calculate the most commonly used rates, like sensitivity or precision, but I couldn’t find one that didn’t…

Continue Reading

Running RStudio Server with R-4.2.2 with Docker

Last updated: 2023/02/28 Recently I have gotten several messages from users having problems with running RStudio Server with the latest R version (4.2.2) from The Rocker Project. The latest RStudio Server image is based on r-ver:4.2.2, which is based on ubuntu:jammy (Ubuntu 22.04). The RStudio Server image for r-ver:4.2.0 is based on ubuntu:focal (Ubuntu 20.04)….

Continue Reading

Backticks in R

The only times I used backticks in R was when a file was imported into R and the column names had spaces (as a side note, please don’t use spaces in your column or file names but use an underscore, i.e. _). For example, you can access col a by using backticks. my_df <- data.frame(…

Continue Reading