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
| ## help | |
| #http://stackoverflow.com/questions/1395528/scraping-html-tables-into-r-data-frames-using-the-xml-package | |
| ### load the libraries | |
| library(RCurl) | |
| library(XML) | |
| ## URL | |
| URL.1 <- "http://www.kiplinger.com/tools/privatecolleges/index.php?table=prv_univ" | |
| URL.2 <- "http://www.kiplinger.com/tools/privatecolleges/index.php?table=lib_arts" |
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
| ############################################################################### | |
| # Author: @BrockTibert | |
| # | |
| # Used: R Version 2.12.1, Windows 7 Pro, StatET Plugin for Eclipse | |
| # | |
| # | |
| ############################################################################### | |
| #----------------------------------------------------------------------- | |
| # set up script level basics |
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
| --- | |
| # My First Slide |
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
| user_credentials <- function() { | |
| # capture the user name | |
| U <- readline("Account username: ") | |
| # capture the password | |
| P <- readline("Account password: ") | |
| # return the data as a list | |
| return(list(U,P)) | |
| } |
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
| ## load the packages | |
| require(XML) | |
| require(RCurl) | |
| require(rjson) | |
| require(plyr) | |
| ## will create a request to the twitter search API - returns JSON | |
| ## https://dev.twitter.com/docs/api/1/get/search | |
| ## max combo can be 1500 tweets (100*15 pages) | |
| ## API limit = 150 requests / hour for requests that are not authenticated |
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(devtools) | |
| Loading required package: devtools | |
| Warning message: | |
| package ‘devtools’ was built under R version 2.15.2 | |
| > install_github("slidify", "ramnathv") | |
| Installing github repo(s) slidify/master from ramnathv | |
| Installing slidify.zip from https://api.github.com/repos/ramnathv/slidify/zipball/master | |
| Installing slidify | |
| Installing dependencies for slidify: | |
| yaml |
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
| ## act to sat concordance chart | |
| ## http://www.act.org/aap/concordance/pdf/reference.pdf | |
| act <- (36:11) | |
| sat <- c(1600, 1560, 1510, 1460, 1420, 1380, 1340, 1300, 1260, 1220, 1190, | |
| 1150, 1110, 1070, 1030, 990, 950, 910, 870, 830, 790, 740, 690, 640, | |
| 590, 530) | |
| act2sat <- data.frame(act, sat) |
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 works as expected | |
| ```{r} | |
| library(rjson) | |
| # comment | |
| 2+2 | |
| ``` | |
| This doesn't print properly | |
| ```{r, eval=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
| #! /bin/bash | |
| # remove the lines below here before running------ | |
| # Example 7: connect into the twitter firehouse - best approach is to use Command Line - run in Ubuntu 11.10 | |
| # Attempted to do this within R, but different approaches proved computing resources get consumed at incredible rate | |
| # need to make this file executable from a command line in a linux-type environment (run in Ubuntu) by chmod 755 | |
| # saves datafile every hour (closes curl, reopens curl) from the twitter sample firehouse, raw json, should be able to process raw data in R and elsewhere | |
| # If you're already in the directory containing the file you could just type: ./filename.sh and press Enter. | |
| while true; do | |
| curl -s -m 3600 -u twitterusername:twitterpassword https://stream.twitter.com/1/statuses/sample.json -o "twtstream_$(date +%Y%m%d%H).txt" |
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
| ############################################################################### | |
| ## Use R to scrape the US News College List and look at yield distribution | |
| ## @brocktibert | |
| ## jan 2013 | |
| ############################################################################### | |
| ## load the necessary packages | |
| require(XML) | |
| require(RCurl) |