Skip to content

Instantly share code, notes, and snippets.

View neilfws's full-sized avatar

Neil Saunders neilfws

View GitHub Profile
@neilfws
neilfws / welcome.md
Last active November 25, 2021 00:49
Stock first comment for new Stack Overflow [r] questions :)

Welcome to Stack Overflow. We cannot read data into R from images. Please make this question reproducible by including a small representative dataset in a plain text format - for example the output from dput(yourdata), if that is not too large.

Here are the names of the deb packages that you can *sudo apt-get install* on Ubuntu-like systems,
to install Perl dependencies for biopieces:
libmodule-build-perl
libbit-vector-perl
libsvg-perl
libterm-readkey-perl
libdbi-perl
libxml-parser-perl
libcarp-clan-perl
---
title: "ztable"
author: "Neil Saunders"
date: "19 March 2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
# function to make the cloud
# assumes rtweet authentication configured as per documentation
make_tweetcloud <- function(user = "neilfws", tweets = 100) {
require(tidyverse)
require(tidytext)
require(rtweet)
require(wordcloud)
get_timeline(user, n = tweets, full_text = TRUE) %>%
@neilfws
neilfws / gantt.R
Created April 13, 2010 13:59
Gantt chart (per day) using ggplot2
library(ggplot2)
# read data file tasks.csv - it looks like this:
# task,date,start,end
# task1,2010-03-05,09:00:00,13:00:00
# task2,2010-03-06,10:00:00,15:00:00
# task3,2010-03-06,11:00:00,18:00:00
# task4,2010-03-07,08:00:00,11:00:00
# task5,2010-03-08,14:00:00,17:00:00
# task6,2010-03-09,12:00:00,16:00:00
# taken from the fifer package
# https://github.com/dustinfife/fifer
excelCols <- function (n)
{
vec1 = LETTERS
if (n <= 26) {
res = vec1[seq_len(n)]
}
else if (n > 26 & n <= 702) {
@neilfws
neilfws / mappify.R
Created August 29, 2017 06:39
Mappify API in R example
library(httr)
req <- POST("http://mappify.io/api/rpc/address/geocode/",
body = list(streetAddress = "252 Botany St",
suburb = "Sydney",
postCode = "2000",
state = "NSW"),
encode = "json")
res <- content(req, "parsed")
@neilfws
neilfws / pmid2bibtex.rb
Last active July 5, 2017 14:32
BioRuby: convert a PubMed PMID to BibTeX citation format
# pmid2bibtex.rb
# convert a PubMed PMID to BibTeX citation format
# updated version of http://chrisamiller.com/science/2010/12/13/using-bioruby-to-fetch-citations-from-pubmed/
# works as of 2015-03-18
require 'bio'
Bio::NCBI.default_email = "me@me.com" # required for EUtils
id = "18265351"
pm = Bio::PubMed::efetch(id) # array of MEDLINE-formatted string
@neilfws
neilfws / basic_rentrez.R
Last active June 30, 2017 04:49
The very basics of PubMed search using rentrez
library(rentrez)
# search for "epigenetics"
es <- entrez_search("pubmed", "epigenetics")
es$count
[1] 20759
# search for "epigenetics" published in 2014
# for all publications in 2014 just drop the "epigenetics"
es <- entrez_search("pubmed", "epigenetics 2014[dp]")
# taken from http://sciencecases.lib.buffalo.edu/cs/files/mini_eco_stats.pdf
#
# NATIONAL CENTER FOR CASE STUDY TEACHING IN SCIENCE
# Mini Cases on Choosing Appropriate
# Statistical Tests for Ecological Data
# by
# Alyssa M. Gleichsner, Department of Biological Sciences
# Elizabeth A. Flaherty, Department of Forestry and Natural Resources
# Purdue University, West Lafayette, IN
# Instructions