Skip to content

Instantly share code, notes, and snippets.

View Libardo1's full-sized avatar

Libardo Lopez Libardo1

  • Bogotá, Colombia
View GitHub Profile
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)
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"
@Libardo1
Libardo1 / july4.R
Created August 1, 2014 14:42 — forked from cwickham/july4.R
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)),
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")))
library(shiny)
library(ggplot2)
# Define server logic required to generate and plot a random distribution
shinyServer(function(input, output) {
generate_data <- reactive(
function(){
mu <- c(input$mu_1, input$mu_2, input$mu_3)
tmp <- data.frame(len = rnorm(length(mu) * input$n,
mean = rep(mu, each = input$n),
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"
#------------------------------------------------------------
# REVOLUTION ANALYTICS WEBINAR: INTRODUCTION TO R FOR DATA MINING
# February 14, 2013
# Joseph B. Rickert
# Technical Marketing Manager
#
# BIG DATA with RevoScaleR
#
# Copyright: Revolution Analytics
@Libardo1
Libardo1 / index.html
Created November 11, 2014 16:52
myPlot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://ramnathv.github.io/rCharts/libraries/widgets/polycharts/js/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
easterEgg.BadWorder.list={
"4r5e":1,
"5h1t":1,
"5hit":1,
a55:1,
anal:1,
anus:1,
ar5e:1,
arrse:1,
arse:1,
@Libardo1
Libardo1 / tokenizer.R
Last active August 29, 2015 14:17 — forked from nonsleepr/tokenizer.R
ngrams.tokenizer <- function(x, n = 2) {
trim <- function(x) gsub("(^\\s+|\\s+$)", "", x)
terms <- strsplit(trim(x), split = "\\s+")[[1]]
ngrams <- vector()
if (length(terms) >= n) {
for (i in n:length(terms)) {
ngram <- paste(terms[(i-n+1):i], collapse = " ")
ngrams <- c(ngrams,ngram)
}
}