Skip to content

Instantly share code, notes, and snippets.

View jennybc's full-sized avatar

Jennifer (Jenny) Bryan jennybc

View GitHub Profile
> session_info("xml2")$packages
package * version date source
BH 1.60.0-2 2016-05-07 CRAN (R 3.2.5)
Rcpp 0.12.5 2016-05-14 cran (@0.12.5)
xml2 0.1.2.9000 2016-05-26 Github (jimhester/xml2@88150bc)
> library(xml2)
> x <- read_xml('
+ <catalog xmlns="http://www.edankert.com/examples/">
+ <cd>
+ <artist>Sufjan Stevens</artist>
@jennybc
jennybc / xml-default-namespace-rage.R
Created May 21, 2016 22:12
xml default namespace rage
#' ---
#' output: github_document
#' ---
#+ setup, include = FALSE
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
error = TRUE
)
@jennybc
jennybc / styles-no-prefix.xml
Created May 21, 2016 19:35
XML default namespace woes
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<numFmts count="1">
<numFmt numFmtId="164" formatCode="&quot;$&quot;#,##0.00"/>
</numFmts>
<fonts count="4">
<font>
<sz val="10.0"/>
<color rgb="FF000000"/>
<name val="Arial"/>
@jennybc
jennybc / 27_feed-node-XML.xml
Last active May 13, 2016 16:43
27_test-drive-new-xml2
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gs="http://schemas.google.com/spreadsheets/2006">
<id>SOME_URL</id>
<entry>
<batch:id>A1</batch:id>
<batch:operation type="update"/>
<id>https://spreadsheets.google.com/feeds/cells/1tP1SAErOJbMrTTCONdL0a9lwe3KkhTuZaGhCy3MPZP8/ozf3txt/private/full/R1C1</id>
<link rel="edit" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/cells/1tP1SAErOJbMrTTCONdL0a9lwe3KkhTuZaGhCy3MPZP8/ozf3txt/private/full/R1C1/fu9n6e"/>
<gs:cell row="1" col="1" inputValue="country"/>
</entry>
<entry>
@jennybc
jennybc / polygraphing-films.R
Created April 9, 2016 16:46
Get polygraphing's film data into R
## http://polygraph.cool/films/
## https://github.com/matthewfdaniels/scripts
x <- "https://raw.githubusercontent.com/matthewfdaniels/scripts/master/data/character_list5.csv"
characters <- read.csv(x, na.strings = c("NULL", "?"),
fileEncoding = "ISO-8859-1", stringsAsFactors = FALSE)
## some ages are clearly (negative) birth years ... oops
characters$age[!is.na(characters$age) & characters$age < 0] <- NA
characters$age[!is.na(characters$age) & characters$age > 105] <- NA
@jennybc
jennybc / github_rx.txt
Last active April 22, 2016 15:13
Parse a concise GitHub repo specification
^(?:(?:([^/]+)/)?([^/@#]+)(?:/([^@#]*[^@#/]))?(?:(?:@([^*].*))|(?:#([0-9]+))|(?:@([*]release)))?|(.*))$
---
title: "A Perfect Storm"
output: html_document
---
```{r}
options(knitr.table.format = 'markdown')
```
@jennybc
jennybc / put-jpg-into-google-sheet-from-r.R
Last active March 2, 2016 10:48
Put a JPG in a Google Sheet cell from R
library(googlesheets)
cdp <- "http://i.imgur.com/lrg4uy5.jpg"
cell_contents <- paste0("=IMAGE(\"", cdp, "\", 2)")
ss <- gs_new("cute-dog-photo-in-cell-2", input = cell_contents)
gs_browse(ss) ## you'll have to change the row size in the browser
## ss$browser_url
@jennybc
jennybc / oliver.R
Last active November 28, 2015 00:58
Oliver's open issues
#' ---
#' output:
#' html_document:
#' keep_md: TRUE
#' ---
# install_github("gaborcsardi/gh")
library(gh)
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(purrr))

difference between difftest.txt difftest2.txt

I am John
+butI am not John