Otago Study Group SYSKA

The OtagoStudyGroup Stuff You Should Know About blog

bash translate

tr or “translate or delete characters” is a super useful program on the command line. My most common usage is to convert delimiters in files, such as tab separated to comma separated: tr "\t" "," < tab_separated_file.tsv or to work out how many columns I have by taking the first line of a file and converting the delimiters to new lines and then counting the number of lines: echo -e "col1\tcol2\tcol3" > file. Read more →

Case-insensitive Completion in Bash

Have you ever been annoyed by having to re-type a file you are looking for, just because the filename contains capital letter(s)? Tab-completion can get you closer to the correct filename without knowing what the actual filename is, but it’s not quite smart enough to account for uppercase and lowercase letters (i.e. it’s case-sensitive). For example, if you type coolfile and hit tab to complete the filename coolFile.txt, tab-completion won’t work. Read more →

Using less more effectively

If you’ve ever used bash terminal before, you would have come across the less command at some point. For anyone who is not familiar with less, less is a “paging” command that allows you to view file(s) of interest on your terminal. It is usually the default “pager” (program used to view a document) for a terminal environment that comes with your Unix/Linux operating system. Now, you might ask “why bother using less when you can open it up on a text editor, or even better, point and click on the file”? Read more →

Making it go faster

Recently I have been going through some old code that I needed to rerun. As part of doing so I was taking the opportunity to reimplement it with some new tricks that I have discovered since I wrote it ~2 years ago. This particular script has many, many for loops which I now wanted to replace with purrr::map to make the code cleaner and easier to maintain. As part of using purrr::map I wondered if I could also make the code go faster by parallelising the loop. Read more →

RMarkdown

This webpage gives some examples of a few of the cool additional things that can be done with relative ease when creating and Rmarkdown document. https://holtzy.github.io/Pimp-my-rmd/ Read more →