This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# knit.sh -- Dave Kleinschmidt, April 2013 | |
# streamline knitting of Rnw files from the command line. | |
usage="Usage: $0 input-filename.Rnw [-nolatex] [-notangle]" | |
if [ $# -lt 1 ]; then | |
echo $usage | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simulatation inference for the results of "Alcohol ingestion stimulates mosquito attraction" by O Shirai (2002) | |
# study url: http://www.ncbi.nlm.nih.gov/pubmed/12083361 | |
# this gist based off (excellent) presentation by John Rauser at the Strata + Hadoop 2014 conference | |
# watch the presentation at https://www.youtube.com/watch?v=5Dnw46eC-0o | |
library(magrittr) # Ceci n'est pas un pipe | |
data = "27 21 20 22 21 15 26 12 27 21 31 16 24 19 19 15 23 24 24 19 28 23 19 13 24 22 29 20 20 24 17 18 31 20 20 22 25 28 21 27 21 18 20" | |
numbers <- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#from http://stackoverflow.com/questions/1358003/tricks-to-manage-the-available-memory-in-an-r-session | |
# improved list of objects | |
.ls.objects <- function (pos = 1, pattern, order.by, | |
decreasing=FALSE, head=FALSE, n=5) { | |
napply <- function(names, fn) sapply(names, function(x) | |
fn(get(x, pos = pos))) | |
names <- ls(pos = pos, pattern = pattern) | |
obj.class <- napply(names, function(x) as.character(class(x))[1]) | |
obj.mode <- napply(names, mode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get install nginx -y | |
sudo service nginx start | |
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list' | |
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 | |
gpg -a --export E084DAB9 | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get install r-base -y | |
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################# | |
# Actual solution ################## | |
############################################# | |
library(dplyr) | |
combined <- left_join(users,usersday2,by="id") | |
table(combined$finst.x,combined$finst.y)[c("check","save","both"),c("check","save","both", "none")] | |
# check save both none | |
# check 415 43 215 37 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#joinedData is dataframe | |
# has names(joinedData) > c("BLAH","BLEH","BLUCH","2015-05","2015-06",...) | |
# want to replce NAs with 0s for date columns | |
r <- "\\d{4}.\\d{2}" | |
x <- joinedData[grep(r,names(joinedData))] | |
x[is.na(x)] <- 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//adapted from http://stackoverflow.com/questions/5256583/run-my-own-script-inside-chromes-debugger-console | |
s = document.createElement('script'); | |
s.src = 'https://code.jquery.com/jquery-2.1.4.min.js'; | |
document.body.appendChild(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- open example.html in chrome, select all, copy, paste into email. Send email to self, view email code: --> | |
<div dir=3D"ltr"><div id=3D"header" style=3D"color:rgb(51,51,51);font-famil= | |
y:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:14px;line-h= | |
eight:20px"><h1 class=3D"" style=3D"margin:20px 0px 10px;font-size:36px;fon= | |
t-family:inherit;font-weight:500;line-height:1.1;color:inherit">Report for = | |
email</h1></div><p style=3D"margin:0px 0px 10px;color:rgb(51,51,51);font-fa= | |
mily:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:14px;lin= | |
e-height:20px"><em>A more complicated markdown file</em></p><pre class=3D""= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get -y install nginx | |
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list' | |
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 | |
gpg -a --export E084DAB9 | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get -y install r-base | |
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 | |
sudo /sbin/mkswap /var/swap.1 | |
sudo /sbin/swapon /var/swap.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [vertical screen DP-2] - [horizontal screen DP-3] | |
xrandr --auto --output DP-2 --left-of DP-3 | |
xrandr --output DP-2 --rotate left |
OlderNewer