Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
library(dplyr) | |
library(lubridate) | |
## when will the two friends be in the same town? | |
visits <- data.frame(am_in_town = c( | |
ymd(20140501) %--% ymd(20140520), | |
ymd(20140615) %--% ymd(20140620), | |
ymd(20140701) %--% ymd(20140710), | |
ymd(20141101) %--% ymd(20141112) |
This file contains hidden or 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
library(rvest) | |
library(magrittr) | |
library(tidyr) | |
library(dplyr) | |
library(stringr) | |
character_data <- function(chname){ | |
paste0("http://en.memory-alpha.org/wiki/", chname) %>% | |
html %>% | |
html_nodes(".wiki-sidebar") %>% |
This file contains hidden or 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
library("rvest") | |
library("XML") | |
links_list <- html("http://www.burnaby.ca/City-Services/Building/Permits-Issued.html") %>% | |
html_nodes("#ctl15_nestedList a") | |
## Where do links lead? This is encoded in the attribute "href". First get all the attributes | |
links_attr <- sapply(links_list, xmlAttrs) | |
## We have the attributes! each link just became a single named character |
This file contains hidden or 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
make -Bnd | make2graph -s | circo -Tpng -o out_circ.png |
This file contains hidden or 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
Installing package into ‘/home/andrew/R/x86_64-pc-linux-gnu-library/3.1’ | |
(as ‘lib’ is unspecified) | |
* installing *source* package ‘RTidyHTML’ ... | |
cc -Iinclude -fPIC -c -o access.o access.c | |
cc -Iinclude -fPIC -c -o alloc.o alloc.c | |
cc -Iinclude -fPIC -c -o attrask.o attrask.c | |
cc -Iinclude -fPIC -c -o attrdict.o attrdict.c | |
cc -Iinclude -fPIC -c -o attrget.o attrget.c | |
cc -Iinclude -fPIC -c -o attrs.o attrs.c | |
cc -Iinclude -fPIC -c -o buffio.o buffio.c |
This file contains hidden or 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
#' convert positional information to two columns | |
#' | |
#' Sometimes text is organized by position. This function | |
#' turns positional group labels (e.g headers ) into the levels of a grouping variable | |
#' @param x character vector containing group labels followed by group members | |
#' @param pattern regular expression that identifies the group labels | |
fill_down <- function(x, pattern){ | |
## find matches of the pattern | |
x <- as.character(x) | |
value_matches <- grepl(pattern = pattern, x = x) |
This file contains hidden or 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
require("yaml") | |
require("lubridate") | |
#' Make a correct SWC blog post | |
#' | |
#' Automatically formats the necessary YAML header for a | |
#' Software Carpentry Teacher training blog post. Writes | |
#' this header to a file with the correct name. The file is | |
#' created in your current working directory. | |
#' |
This file contains hidden or 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
print_num <- function(num){ | |
print(num) | |
} | |
print_num_x <- function(num = x){ | |
print(num) | |
} |
This file contains hidden or 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
## create the logical matrices for subsetting | |
## x matrix to subset | |
## n number of rows or columns in each subset (by subset I mean a small square from the larger matrix) | |
select_matrix <- function(x, n){ | |
mod <- ncol(x) %% n | |
if(mod != 0) stop("not a divisor") | |
if(ncol(x) != nrow(x)) stop("not a square") | |