Skip to content

Instantly share code, notes, and snippets.

@mdavy86
mdavy86 / gist:c0d40c9f16f7bb6d32d7
Last active December 14, 2015 19:32
knitr inline R code error

In line functions

Only loading the library for the session Information

library(knitr)

The following user defined function works:

@mdavy86
mdavy86 / gist:1d9ce6ec331d9603da3b
Last active December 14, 2015 19:32
knitr scan error

Parsing scan()

library(knitr)

Some people use scan to load small amounts of data into R

@mdavy86
mdavy86 / gist:d443c0e066f45530430a
Last active October 6, 2023 15:38
Finding stuff in bash

Finding files containing specific content of interest

grep and find are two utilities for searching, grep searches for content within files, find searches for file names themselves.

Using grep

Defining some additional options in grep allows searching using colour where filenames and row positions are highlighted.

@mdavy86
mdavy86 / 0_reuse_code.js
Created June 12, 2014 01:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mdavy86
mdavy86 / eBridaIdentifiers.md
Last active August 29, 2015 14:16 — forked from cfljam/new_gist_file.r
Fixing eBrida identifiers

Problem

Incorrectly formatting of Vine identifiers from Excel sources for eBrida. For example, the identifier

Incorrect Excel format conversion Correct eBrida format
TO8.33.06.15F => T08.33-06-15f

@mdavy86
mdavy86 / Vcf2DT.md
Created August 1, 2016 20:04 — forked from cfljam/Vcf2DT.md
howto parse phased vcf file with R data.table

HOWTO Parse vcf to DT

John McCallum 15 July 2016

Goal

  • work out tidiest way to split up haplotypes from phased vcf in data.table for plotting haplotypes
@mdavy86
mdavy86 / Reverse Pivot in Excel
Created November 16, 2016 00:38 — forked from leeogrady/Reverse Pivot in Excel
Covert Wide table to Long...
- Click anywhere within the data table
- Hit the key combination Alt - d - p to bring up the Pivot Table Wizard (which is not on the ribbon)
- Select "Multiple consolidation ranges" and click Next
- Select "I will create the page fields" and click Next
- Select your data table (in the example it's A1:E11) and click Next
- Select the location and click Next
Now you will see a pivot table that looks just like your data table
- Click the Pivot table and in the field list uncheck Row and Column (and uncheck any Page Field, if present)
- Now select the cell with the single remaining total number and double click it.
The result is a new sheet with your data laid out one item per row.

Learning Python

Getting Started with Python

There are a huge range of tutorials and books available for learning Python. There are a couple things to watch out for when selecting learning material:

  1. Python 2 & 3 are very similar but subtly different languages. This can be a bit of a pain point when first learning Python so be aware of what version a tutorial or book is demonstrating. I highly recommend sticking to Python 3 as Python 2 is slowly being phased out of existence.
  2. Python is a very general purpose language (e.g. compared to R) so a lot of material is focused on web development, games and etc. The style of code used can be different between these topics so try to find learning material from an appropriate domain.

Bellow is a list of resources that are generally more focussed towards science and numerical programming rather than other topics (e.g. web development). I have used parts of most of these or otherwise trust the source of the material.