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(sp) | |
| library(tmap) | |
| library(tigris) | |
| # devtools::install_github("cwickham/geospatial") | |
| library(geospatial) | |
| nyc_tracts <- tracts(state = "NY", county = "New York", cb = TRUE) | |
| nyc_tracts_merge <- merge(nyc_tracts, nyc_income, by.x = "TRACTCE", by.y = "tract") | |
| qtm(nyc_tracts_merge, fill = "estimate") |
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
| # edited from init_oauth2.0 to: | |
| # * add trailing slash to callback | |
| # * add base64 encoded client_id:client_secret to request when exchanging | |
| init_oauth2.0_fitbit <- function(endpoint, app, scope = NULL, type = NULL, | |
| use_oob = getOption("httr_oob_default"), | |
| is_interactive = interactive()) { | |
| if (!use_oob && !httr:::is_installed("httpuv")) { | |
| message("httpuv not installed, defaulting to out-of-band authentication") | |
| use_oob <- TRUE |
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(stringr) | |
| library(RCurl) | |
| #Google polyline decoder borrowed from: | |
| #http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/decode.js | |
| DecodeLineR <- function(encoded) { | |
| len = str_length(encoded) | |
| encoded <- strsplit(encoded, NULL)[[1]] | |
| index = 1 | |
| N <- 100000 |
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
| --- | |
| title: "F-test exercises" | |
| author: "ST552 Winter 2015" | |
| date: "January 23, 2015" | |
| output: html_document | |
| --- | |
| > In a study of cheddar cheese from the LaTrobe Valley of Victoria, Australia, samples of cheese were analyzed for their chemical composition and were subjected to taste tests. Overall taste scores were obtained by combining the scores from several tasters. | |
| > |
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
| # devtools::install_github("lintr", "jimhester") | |
| library(lintr) | |
| library(magrittr) | |
| # stuff to fix buggy lintr package | |
| split_chain <- magrittr:::split_chain | |
| wrap_function <- magrittr:::wrap_function | |
| is_placeholder <- magrittr:::is_placeholder | |
| is_compound_pipe <- magrittr:::is_compound_pipe | |
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
| > PUT("https://canvas.instructure.com/api/v1/courses/890522/pages/my-new-page", | |
| + body = list("wiki_page[body]"= paste(readLines("test-simple.html"), collapse = "\n")), | |
| + add_headers("Authorization" = paste0("Bearer ", token)), verbose()) | |
| -> PUT /api/v1/courses/890522/pages/my-new-page HTTP/1.1 | |
| -> User-Agent: curl/7.30.0 Rcurl/1.95.4.1 httr/0.4.0.99 | |
| -> Host: canvas.instructure.com | |
| -> Accept: */* | |
| -> Accept-Encoding: gzip | |
| -> Cookie: _csrf_token=R%2FAKhdtpkRA0HlWiFs4W%2B%2Bmu77rW7bM9XuUsvOa%2Bvc0Q32Hs7gzrYx9WfvRDjHK0i8yAzr7Y8FMo0WDQ05Xyuw%3D%3D; canvas_session=TPgoJzbRWborci-ryiUD9A.YcHtPu1gIj92ifvQL5cJY0A7GSoRD1VKXyuwQDR2dbsXl-LG-wsDyqYnpJ2wkOS-sjEfLPPpwT3i7lw-tsWa5mS4jMyVQROjcas_0ojuypKooSlaRrVmh8pofrfnLBZBh6iaPzTjeiVkzOZe3W1bXw.AU-3cNhCsO3pM8yv5mNNw22tBtg.VEVt-g | |
| -> Authorization: Bearer 7~lzo8qNB80Ta0D6oq3tGVW9TzFs5MXbnA3FmEOIHzbQ5U2nOzuFV7n7TEq9dCpCPg |
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(httr) | |
| library(ggplot2) | |
| add_cat <- function(width = 400, height = 400){ | |
| r <- GET(paste("http://theoldreader.com/kittens", width, height, sep = "/")) | |
| stop_for_status(r) | |
| img <- content(r) | |
| bw <- 0.2989*img[,,1] + 0.5870*img[,,2] + 0.1140*img[,,3] | |
| lighter <- bw + (0.7 * (1-bw)) | |
| annotation_raster(lighter, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf) |
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(proto) | |
| stat_qqline <- function (mapping = NULL, data = NULL, geom = "abline", position = "identity", | |
| distribution = qnorm, dparams = list(), na.rm = FALSE, ...) { | |
| StatQqline$new(mapping = mapping, data = data, geom = geom, position = position, | |
| distribution = distribution, dparams = dparams, na.rm = na.rm, ...) | |
| } | |
| StatQqline <- proto(ggplot2:::Stat, { | |
| objname <- "qqline" |
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(plyr) | |
| library(ggplot2) | |
| # from: http://www.codeproject.com/Articles/18149/Draw-a-US-Flag-using-C-and-GDI | |
| star_coords <- function(x, y, r, r1){ | |
| a <- 72 * pi /180 | |
| b <- a/2 | |
| df <- data.frame( | |
| x = x + c(0, r1*sin(b), r*cos(pi/2 - a), r1*cos(a + b - pi/2), r*sin(b), | |
| 0, -r*sin(b), -r1*cos(a + b - pi/2), - r*cos(pi/2 - a), -r1*sin(b)), |
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
| fitted_variofit <- function (x, max.dist, scaled = FALSE, ...) { | |
| my.l <- list() | |
| if (missing(max.dist)) { | |
| my.l$max.dist <- x$max.dist | |
| if (is.null(my.l$max.dist)) | |
| stop("argument max.dist needed for this object") | |
| } | |
| else my.l$max.dist <- max.dist | |
| if (any(x$cov.model == c("matern", "powered.exponential", | |
| "cauchy", "gencauchy", "gneiting.matern"))) |