Otago Study Group SYSKA

The OtagoStudyGroup Stuff You Should Know About blog

Bash history

One of the most useful additions to my .bashrc file that I have found is the addition of this command to save all the commands that I run into a log file. export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi' This is super useful because it saves a new file for each day of all of the timestamped commands that I have run and the directory I was in when I ran them. Read more →

usethis - project setup

One of the packages that was a highlight for me from rstudio::conf2018 was usethis. This package forms part of the package building workflow but also general project workflows. In a package development workflow some of the key functions are: # creates a new dir and populates with a skeleton containing examples usethis::create_package("/path/to/create/package") # creates an R script in the R/ dir (don't need to include the .R extension) usethis::use_r("filename") # series of license templates such as mit, gpl3, cc0 etc usethis::use_*_license_license("name") # initialises a testthat dir to put tests usethis::use_testthat() # creates a testfile usethis::use_test("filename") # creates a README file for your package usethis::use_readme_md() Read more →

aRson threats and some best practices

Recently on twitter - the source of most of these posts - Jenny Bryan (@JennyBryan) posted a link to her slides from her talk she gave in Auckland (http://bit.ly/jenny-nz). It inpsired threats of arson for people that use setwd("/absolute/path/to/file") (this was because it reduces portability and outside of you using it the chances of someone having the exact directory setup is basically 0%) and rm(list = ls()) (because it interferes with peoples sessions and doesn’t sort out other session issues such as packages already loaded) Read more →

Github Education Account

For people that aren’t aware, students are able to get private repos on github for free! On top of this there is also a bunch of other free tools that come along with this pack To sign up for the pack head to https://education.github.com and follow the links. It is also possible to get academic discount for academic accounts so it’s also worth checking it out. Read more →

Parallel install of R packages

This came up in my twitter feed from Rbloggers and looks pretty useful as a set and forget type thing. See https://www.r-bloggers.com/speeding-up-package-installation-2/ for the actual post Basically, install.packages() uses the environment setting for Ncpus, which by default is set to 1. The current setting can be found with # the second argument returns 1 if Ncpus is not set, instead of NULL getOption("Ncpus", 1L) Ncpus can be set with this command before running install. Read more →