| Models | Examples | 
|---|---|
| Display ads | Yahoo! | 
| Search ads | 
  
    
      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
    
  
  
    
  | # Simple script for doing some data-analysis of tweets; | |
| # looking at "sentiment" and "emotion" using the sentiment package. | |
| # see https://sites.google.com/site/miningtwitter/questions/sentiment/sentiment | |
| # for background. | |
| # SETTINGS | |
| # ============================================================================= | |
| authenticated = TRUE # If TRUE will load credential from file. | |
| tweets.from.file = TRUE # If TRUE will load tweets from file rather than query. | |
| no.tweets = 1500 # Number of tweets to fetch in every search; <= 1,500. | 
  
    
      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(ggplot2) | |
| library(reshape) | |
| library(scales) | |
| ### INSTRUCTIONS | |
| # 1. Save file to same local directory | |
| # 2. Change time zone specification in third IMPORT DATA statement | |
| # 3. In each top_n_for_hour or top_n_for_day, test to statistical significance by comparing the result of the top_n function and the result of the matrix t test | |
  
    
      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
    
  
  
    
  | #While this particular version takes files of the text on my followers and following pages, | |
| #it can be easily modified to check a past list of followers against a more recent list - | |
| #just replace following.txt with the "past followers" file and followers.txt with "present followers". | |
| #encoding may be 'utf-8' depending on the type of files you are using | |
| with open('following.txt', 'r', encoding = 'latin-1') as following_file: | |
| with open('followers.txt', 'r', encoding = 'latin-1') as followers_file: | |
| discrepancy = set(following_file).difference(followers_file) | 
  
    
      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
    
  
  
    
  | Example analysis-fitting linear models to iris data set | |
| ======================================================== | |
| * Name: iris-lm-demo.Rmd | |
| * Date: June 12, 2014 | |
| * Author: Phillip Burger | |
| ```{r setup, message=FALSE, echo=FALSE} | |
| options(width = 80, prompt = '>> ') | |
| setwd("~/") | |
| opts_chunk$set(out.width=650 , fig.align='center') | |
| opts_knit$set(progress = TRUE, warning = TRUE, message=FALSE) | 
  
    
      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(RMySQL) | |
| library(rms) | |
| gga_host<-Sys.getenv("GGA_HOST") | |
| gga_user<-Sys.getenv("GGA_USER") | |
| gga_password<-Sys.getenv("GGA_PASSWORD") | |
| gga_database<-Sys.getenv("GGA_DATABASE") | |
| con <-dbConnect(MySQL(), user = gga_user, password = gga_password, host = gga_host, dbname = gga_database) | 
  
    
      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
    
  
  
    
  | ############################################################################### | |
| # This program is free software: you can redistribute it and/or modify | |
| # it under the terms of the GNU General Public License as published by | |
| # the Free Software Foundation, either version 3 of the License, or | |
| # (at your option) any later version. | |
| # | |
| # This program is distributed in the hope that it will be useful, | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| # GNU General Public License for more details. | 
  
    
      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
    
  
  
    
  | #to make the final table, I changed manually the n size every trial by: 1e3, 1e4, 1e5, 1e6, 1e7. Then I also chnaged the benchmark object 'res' | |
| n <- 1e7 | |
| set.seed(51) | |
| process <- data.frame(id=sample(100, n, rep=T), x=rnorm(n), y=runif(n), z=rpois(n, 1) pexp(2, rate=1/3) ) | |
| all <- multicore:::detectCores(all.tests=TRUE) | |
| if(!require(rbenchmark)){ | |
| install.packages("rbenchmark") | |
| } else{ | 
  
    
      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
    
  
  
    
  | # Simplest possible marimekko/mosaic plot | |
| doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
| toInstall <- c("vcd", "ggplot2", "RColorBrewer") | |
| if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
| lapply(toInstall, library, character.only = TRUE) | |
| theme_set(theme_gray(base_size = 7)) | |
| # All you need to start with is individual count data, and a grouping variable | 
  
    
      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
    
  
  
    
  | #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"){ | 
NewerOlder