Cost ($) | Item(s) |
library(rtweet) #rtweet API creds should already be set up | |
library(stringi) | |
library(dplyr) | |
friends = get_friends(user="noamross") | |
followers = get_followers("noamross") | |
tweeps_id = distinct(bind_rows(friends, followers)) | |
tweeps_info = lookup_users(tweeps_id$user_id) | |
# A regex for a visit to Durham |
# Created 2016-03-04 Fri 20:20 | |
#+TITLE: R | |
#+AUTHOR: Ross Donaldson | |
* Object Oriented, Functional, and Imperative Programming | |
Right OK: what are these three things? What do they do and how are they | |
different? | |
Let's just assume you're using an Ubuntu-ish distro of Linux. In some ways that makes
this a little more complicated, but on the other hand, it lets me assume you have experience
with other package managers. So the big thing here is that conda
is it's own little scientific
apt-get
(python packages, GIS tools, R + R packages, gcc, etc) that goes off and builds sandboxes
contained in individual rooms. Then there's pip
. Pip is specifically for python packages only and
in my opinion, should only be used when the conda package isn't available.
Back to conda: conda is a package manager that depends on python, but is not per se an installation of python. So:
--- | |
title: "Row bind a list of data.frames with a key" | |
author: "Jenny Bryan" | |
date: "22 August, 2014" | |
output: | |
html_document: | |
keep_md: TRUE | |
--- | |
I posed a question on Twitter (click to see the figure!): |
Is there an easy way to convert a named list into a dataframe, preserving the elements of the list in a "list-column"?
library(dplyr)
library(magrittr)
## make a random matrix
rand_mat <- function() {
coalesce<-function(...) { | |
x<-lapply(list(...), function(z) {if (is.factor(z)) as.character(z) else z}) | |
m<-is.na(x[[1]]) | |
i<-2 | |
while(any(m) & i<=length(x)) { | |
if ( length(x[[i]])==length(x[[1]])) { | |
x[[1]][m]<-x[[i]][m] | |
} else if (length(x[[i]])==1) { | |
x[[1]][m]<-x[[i]] | |
} else { |
################################ | |
# Problem: You have a ragged | |
# data frame where species that have not | |
# been seen as a site simply don't have a | |
# line in your data frame. You have a long | |
# data frame, but you want a long data frame | |
# where missing species have proper zeroes | |
# | |
# Solution: a combination of dcast and melt | |
# from the reshape2 package |
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
data_sets <- c("mtcars", "morley", "rock") | |
shinyServer(function(input, output) { | |
# Drop-down selection box for which data set | |
output$choose_dataset <- renderUI({ | |
selectInput("dataset", "Data set", as.list(data_sets)) | |
}) | |
# Check boxes |