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
library(shiny) | |
library(animation) | |
library(Cairo) | |
library(pitchRx) | |
library(shinyRGL) | |
library(rgl) | |
valid <- function(input, default) { | |
if (is.null(input)) return(FALSE) |
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
#Taken from http://rstudio.github.com/shiny/tutorial/#hello-shiny | |
#All credits to Joe Cheng | |
library(shiny) | |
# Define server logic required to generate and plot a random distribution | |
shinyServer(function(input, output) { | |
# Function that generates a plot of the distribution. The function | |
# is wrapped in a call to reactivePlot to indicate that: |
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
#template for fixing bad xml files from nba.com | |
library(XML) | |
con <- url("http://www.nba.com/games/game_component/dynamic/20130528/MIAIND/pbp_all.xml") | |
corrupt <- readLines(con) | |
close(con) | |
tmp <- gsub("<![CDATA[", "", corrupt, fixed=TRUE) #do I really need "<![CDATA"? | |
file <- gsub("]]>", "", tmp, fixed=TRUE) #do I really need "]]>"? | |
doc <- xmlParseString(xml(file)) | |
node <- getNodeSet(doc, path="/") | |
l <- xmlToList(node[[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
setwd("~/Downloads") | |
obs <- XML2Obs("out.xml", url.map=TRUE) | |
unique(names(obs)) #you might want to re_name or add_key before collapsing | |
tables <- collapse(obs) | |
head(tables[["osm//node//tag"]]) |
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
library(shiny) | |
library(ggvis) | |
x <- seq(-4, 4, .1) | |
dat <- data.frame(x, y=dnorm(x)) | |
g1 <- ggvis(dat, props(x = ~x, y = ~y), mark_path()) | |
shinyServer(function(input, output, session) { | |
# A subset of mtcars | |
dat2 <- reactive({ dat[dat$x <= input$z,] }) |
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
#This example will require version 0.0.5 of XML2R | |
library(devtools) | |
install_github("XML2R", "cpsievert") | |
library(XML2R) | |
#you could use multiple files here if you wanted... | |
files <- "https://www.misoenergy.org/ria/Consolidated.aspx?format=xml" | |
obs <- XML2Obs(files) | |
names(obs)[grep("PricingNode", names(obs))] <- "PricingNode" | |
tables <- collapse_obs(obs) | |
head(tables[[5]]) |
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
library(XML2R) | |
file <- "http://stats.oecd.org/restsdmx/sdmx.ashx/GetData/UN_DEN/AUS+CAN+FRA+DEU+NZL+GBR+USA+OECD/OECD?startTime=1960&endTime=2012" | |
obs <- XML2Obs(file) | |
# Rename observations so we can 'recycle' country labels to time/value | |
nms <- names(obs) | |
nms[grepl("SeriesKey//Value$", nms)] <- "root" | |
nms[grepl("Obs//Time$", nms)] <- "root//time" | |
nms[grepl("Obs//ObsValue$", nms)] <- "root//value" |
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
library(pitchRx) | |
library(dplyr) | |
library(mgcv) | |
# Establish a SQLite database connection | |
my_db <- src_sqlite("pitchRx.sqlite3") | |
# DISLCAIMER: this 'pitchfx.sqlite3' database was obtained using pitchRx version 1.2 | |
# The code below probably won't work if you are using data collected from earlier versions or other methods | |
# Anyway, if you want to recreate this analysis, make sure you have pitchRx 1.2 or higher, then run: |
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
--- | |
output: | |
knitrBootstrap::bootstrap_document: | |
title: "Stat 226 Home Page" | |
theme: amelia | |
highlight: sunburst | |
theme.chooser: TRUE | |
highlight.chooser: TRUE | |
bootstrap.panel: FALSE | |
--- |
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
library(XML) | |
library(RCurl) | |
library(stringr) | |
library(elife) | |
# Obtain all the dois! Well, at least every one on GitHub. | |
# Should/could this be an option in searchelife? It doesn't take that long... | |
con <- getURL("https://github.com/elifesciences/elife-articles") | |
doc <- htmlParse(con, asText = TRUE) | |
nodes <- getNodeSet(doc, path="//a[@class='js-directory-link']") |
OlderNewer