Skip to content

Instantly share code, notes, and snippets.

View jdeboer's full-sized avatar

Johann de Boer jdeboer

View GitHub Profile
@abelsonlive
abelsonlive / getInsights.R
Created May 27, 2012 20:09
getInsights - an R API for Google Insights
#see below for query specifications
getInsights <- function(
username = "Insights4R@gmail.com",
password = "googleinsights4r",
text_query = "'hello world'",
date_query = "1/2004 108m",
geo_query = "US",
search_type= "all",
filter_category="none"){
@meefen
meefen / lsa_mds.R
Last active September 30, 2019 20:17
Analyze Text Similarity in R: Latent Semantic Analysis and Multidimentional Scaling
# load required libraries
library(tm)
library(ggplot2)
library(lsa)
# 1. Prepare mock data
text <- c("transporting food by cars will cause global warming. so we should go local.",
"we should try to convince our parents to stop using cars because it will cause global warming.",
"some food, such as mongo, requires a warm weather to grow. so they have to be transported to canada.",
"a typical electronic circuit can be built with a battery, a bulb, and a switch.",
@corynissen
corynissen / google_prediction_api_example
Created June 13, 2013 15:46
google prediction api example
library(rjson)
library(RCurl)
client_id <- "client id here"
client_secret <- "client secret here"
redirect_uri <- "https://localhost/oauth2callback"
auth_url <- "https://accounts.google.com/o/oauth2/auth"
scope <- "https://www.googleapis.com/auth/prediction"
api_key <- "api key here"
@jdeboer
jdeboer / GAUC2013.R
Last active August 17, 2016 16:27
The R script used during my presentation at GAUC 2013 to join weather data from BoM with web data from Google Analytics.
# Please replace this sample profile ID with that of your own
# Google Analytics profile.
profile_id <- 123456789
# Please ensure you have all of the following libraries
# installed first.
library(ganalytics)
library(httr)
library(XML)
library(lubridate)
@rpietro
rpietro / lsa_hack.r
Created September 3, 2013 23:03
playing with lsa based on post from http://goo.gl/ds2c4p
# script stolen from http://goo.gl/YbQyAQ
# install.packages("tm")
# install.packages("ggplot2")
# install.packages("lsa")
# install.packages("scatterplot3d")
#install.packages("SnowballC")
#if !(require('SnowballC')) then install.packages("SnowballC")
library(tm)
library(ggplot2)
@jebyrnes
jebyrnes / addZeroes.R
Last active August 29, 2015 13:56
A demonstration of how to add rows with zeroes using melt and dcast. There are other ways, but this is pretty simple.
################################
# Problem: You have a ragged
# data frame where species that have not
# been seen as a site simply don't have a
# line in your data frame. You have a long
# data frame, but you want a long data frame
# where missing species have proper zeroes
#
# Solution: a combination of dcast and melt
# from the reshape2 package
@gruber
gruber / Liberal Regex Pattern for Web URLs
Last active April 22, 2024 19:02
Liberal, Accurate Regex Pattern for Matching Web URLs
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "example.com". For a pattern that attempts to
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s
@swayson
swayson / lsa_hack.r
Created February 26, 2014 06:56 — forked from rpietro/lsa_hack.r
Analyze Text Similarity with R: Latent Semantic Analysis and Multidimentional Scaling
# script stolen from http://goo.gl/YbQyAQ
# install.packages("tm")
# install.packages("ggplot2")
# install.packages("lsa")
# install.packages("scatterplot3d")
#install.packages("SnowballC")
#if !(require('SnowballC')) then install.packages("SnowballC")
library(tm)
library(ggplot2)
library(httr)
library(XML)
library(selectr)
xpath <- function(x) structure(x, class = "xpath")
sel <- function(x) xpath(css_to_xpath(x, prefix = "//"))
url <- "http://www.boxofficemojo.com/movies/?id=ateam.htm"
html <- content(GET(url), "parsed")
@MarkEdmondson1234
MarkEdmondson1234 / auth.r
Last active February 24, 2020 22:25
Authenticate a Twitter app in R
# Refer to https://rtweet.info/