Skip to content

Commit

Permalink
Update vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed May 9, 2016
1 parent 5a5118f commit 64f6a96
Show file tree
Hide file tree
Showing 10 changed files with 472 additions and 288 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Description: A fast JSON parser and generator optimized for statistical data
package verify that all edge cases are encoded and decoded consistently for
use with dynamic data in systems and applications.
Suggests:
curl (>= 0.5),
httr,
plyr,
testthat,
knitr,
Expand Down
87 changes: 76 additions & 11 deletions inst/doc/json-aaquickstart.html

Large diffs are not rendered by default.

162 changes: 82 additions & 80 deletions inst/doc/json-apis.Rmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Fetching JSON data from REST APIs"
date: "2015-09-06"
date: "2016-05-09"
output:
html_document
vignette: >
Expand Down Expand Up @@ -34,36 +34,36 @@ paste(format(gg_issues$user$login), ":", gg_issues$title)
```

```
[1] "idavydov : annotate(\"segment\") wrong position if limits are inverted"
[2] "ben519 : geom_polygon doesn't make NA values grey when using continuous fill"
[3] "has2k1 : Fix multiple tiny issues in the position classes"
[4] "neggert : Problem with geom_bar position=fill and faceting"
[5] "robertzk : Fix typo in geom_linerange docs."
[6] "lionel- : stat_bar() gets confused with numeric discrete data?"
[7] "daattali : Request: support theme axis.ticks.length.x and axis.ticks.length.y"
[8] "sethchandler : Documentation error on %+replace% ?"
[9] "daattali : dev version 1.0.1.9003 has some breaking changes"
[10] "lionel- : Labels"
[11] "nutterb : legend for `geom_line` colour disappears when `alpha` < 1.0"
[12] "wch : scale_name property should be removed from Scale objects"
[13] "wch : scale_details arguments in Coords should be renamed panel_scales or scale"
[14] "wch : ScalesList-related functions should be moved into ggproto object"
[15] "wch : update_geom_defaults and update_stat_defaults should accept Geom and Stat objects"
[16] "wch : Make some ggproto objects immutable. Closes #1237"
[17] "and3k : Control size of the border and padding of geom_label"
[18] "hadley : Consistent argument order and formatting for layer functions"
[19] "hadley : Consistently handle missing values"
[20] "cmohamma : fortify causes fatal error"
[21] "lionel- : Flawed `label_bquote()` implementation"
[22] "beroe : Create alias for `colors=` in `scale_color_gradientn()`"
[23] "and3k : hjust broken in y facets"
[24] "joranE : Allow color bar guides for alpha scales"
[25] "hadley : dir = \"v\" also needs to swap nrow and ncol"
[26] "joranE : Add examples for removing guides"
[27] "lionel- : New approach for horizontal layers"
[28] "bbolker : add horizontal linerange geom"
[29] "hadley : Write vignette about grid"
[30] "hadley : Immutable flag for ggproto objects"
[1] "tdsmith : stat_binhex weight aesthetic is undocumented"
[2] "huelf : geom_contour throws error when ggplot aes uses shape"
[3] "davidkretch : Fix typo in Extending ggplot2 vignette"
[4] "janschulz : data used in geom_text with geom specific aes is longer than it should be?"
[5] "janschulz : Add top margin to default plot.caption"
[6] "wch : Preserve class when adding uneval objects"
[7] "coolbutuseless : corrected theme inhertiance for legend.key.size"
[8] "has2k1 : Fix geom_dotplot y limit calculations"
[9] "shreyasgm : Typo in error message while saving large plots"
[10] "DarwinAwardWinner : Ordering of multiple legends is seemingly random"
[11] "noamross : geom_dotplot extends past axis"
[12] "aosmith16 : geom_dotplot negates free y scale from facet_wrap"
[13] "lfaller : How to customize x-axis labels for a stacked bar plot graph?"
[14] "kfeng123 : How can I axis.ticks while using theme_minimal()?"
[15] "richardbeare : Design query - connectograms"
[16] "gcpoole : Plotting SpatialLinesDataFrame connects all of the individual lines"
[17] "zeehio : [Feature Request] different scales by facet"
[18] "salauer : geom_smooth parameters no longer available in qplot"
[19] "luczkovichj : Contour labels using direct.label"
[20] "coolbutuseless : geom_hex/stat_hex binwidth argument no longer working"
[21] "HughParsonage : annotate() won't expand when position aesthetics are length 1"
[22] "whao89 : geom_hex no longer recognizes ..density.. in 2.1.0"
[23] "paul4forest : X axis doesn't appear below facet_wrap plot with uneven number of facets"
[24] "DarioS : Allow a Vector of Numbers for label_wrap_gen's Width Parameter"
[25] "coolbutuseless : stat_bin_2d creates an (almost) unkillable legend."
[26] "dutri001 : Online documentation: HTML table not properly generated from Latex doc "
[27] "krlmlr : Conditional examples are not rendered"
[28] "juliangehring : Facets break grouping of data points"
[29] "holgerbrandl : segfault on macos when using ggsave in parallelized loop "
[30] "JestonBlu : Added new economic theme"
```

## CitiBike NYC
Expand Down Expand Up @@ -94,7 +94,7 @@ nrow(stations)
```

```
[1] 509
[1] 508
```

## Ergast
Expand Down Expand Up @@ -191,7 +191,7 @@ filings[1:10, c("organization.sub_name", "organization.city", "totrevenue")]

## New York Times

The New York Times has several APIs as part of the NYT developer network. These interface to data from various departments, such as news articles, book reviews, real estate, etc. Registration is required (but free) and a key can be obtained at [here](http://developer.nytimes.com/docs/reference/keys). The code below includes some example keys for illustration purposes.
The New York Times has several APIs as part of the NYT developer network. These interface to data from various departments, such as news articles, book reviews, real estate, etc. Registration is required (but free) and a key can be obtained at [here](http://developer.nytimes.com/signup). The code below includes some example keys for illustration purposes.


```r
Expand All @@ -204,13 +204,13 @@ colnames(articles)
```

```
[1] "web_url" "snippet" "lead_paragraph"
[4] "abstract" "print_page" "blog"
[7] "source" "multimedia" "headline"
[10] "keywords" "pub_date" "document_type"
[13] "news_desk" "section_name" "subsection_name"
[16] "byline" "type_of_material" "_id"
[19] "word_count"
[1] "web_url" "snippet" "lead_paragraph"
[4] "abstract" "print_page" "blog"
[7] "source" "multimedia" "headline"
[10] "keywords" "pub_date" "document_type"
[13] "news_desk" "section_name" "subsection_name"
[16] "byline" "type_of_material" "_id"
[19] "word_count" "slideshow_credits"
```

```r
Expand Down Expand Up @@ -242,25 +242,23 @@ colnames(reviews)
```

```
[1] "nyt_movie_id" "display_title" "sort_name"
[4] "mpaa_rating" "critics_pick" "thousand_best"
[7] "byline" "headline" "capsule_review"
[10] "summary_short" "publication_date" "opening_date"
[13] "dvd_release_date" "date_updated" "seo_name"
[16] "link" "related_urls" "multimedia"
[1] "display_title" "mpaa_rating" "critics_pick"
[4] "byline" "headline" "summary_short"
[7] "publication_date" "opening_date" "date_updated"
[10] "link" "multimedia"
```

```r
reviews[1:5, c("display_title", "byline", "mpaa_rating")]
```

```
display_title byline mpaa_rating
1 Tom at the Farm Stephen Holden NR
2 A Little Chaos Stephen Holden R
3 Big Game Andy Webster PG13
4 Balls Out Andy Webster R
5 Mad Max: Fury Road A. O. Scott R
display_title byline mpaa_rating
1 Dheepan A. O. SCOTT R
2 Mothers and Daughters NEIL GENZLINGER PG-13
3 Phantom of the Theater DANIEL M. GOLD
4 Beautiful Something STEPHEN HOLDEN Not Rated
5 Elstree 1976 NEIL GENZLINGER
```

## CrunchBase
Expand Down Expand Up @@ -289,12 +287,18 @@ print(drone_bills[1:5, c("title", "state", "chamber", "type")])
```

```
title state chamber type
1 WILDLIFE-TECH il lower bill
2 Criminalizes the unlawful use of an unma ny lower bill
3 Criminalizes the unlawful use of an unma ny lower bill
4 Relating to: criminal procedure and prov wi lower bill
5 Relating to: criminal procedure and prov wi upper bill
title state chamber
1 An act relating to privacy protection vt upper
2 Crimes: emergency personnel. ca lower
3 DRONE TASK FORCE APPT il lower
4 Omnibus K-12 and higher education policy mn lower
5 Relates to prohibiting civilian drone us ny upper
type
1 bill
2 bill, fiscal committee, local program
3 bill
4 bill
5 bill
```

```r
Expand All @@ -308,11 +312,11 @@ summary(wordcount)
```
count day raw_count
Min. : 1.00 Min. :1996-01-02 Min. : 1.00
1st Qu.: 3.00 1st Qu.:2001-01-22 1st Qu.: 3.00
Median : 8.00 Median :2005-11-16 Median : 8.00
Mean : 25.27 Mean :2005-10-02 Mean : 25.27
3rd Qu.: 21.00 3rd Qu.:2010-05-12 3rd Qu.: 21.00
Max. :1835.00 Max. :2015-08-05 Max. :1835.00
1st Qu.: 3.00 1st Qu.:2001-03-26 1st Qu.: 3.00
Median : 8.00 Median :2006-03-21 Median : 8.00
Mean : 24.91 Mean :2006-01-30 Mean : 24.91
3rd Qu.: 21.00 3rd Qu.:2010-12-08 3rd Qu.: 21.00
Max. :1835.00 Max. :2016-04-27 Max. :1835.00
```

```r
Expand Down Expand Up @@ -340,10 +344,9 @@ consumer_key = "EZRy5JzOH2QQmVAe9B4j2w";
consumer_secret = "OIDC4MdfZJ82nbwpZfoUO4WOLTYjoRhpHRAWj6JMec";

#Use basic auth
library(httr)
secret <- RCurl::base64(paste(consumer_key, consumer_secret, sep = ":"));
req <- POST("https://api.twitter.com/oauth2/token",
add_headers(
secret <- openssl::base64_encode(paste(consumer_key, consumer_secret, sep = ":"));
req <- httr::POST("https://api.twitter.com/oauth2/token",
httr::add_headers(
"Authorization" = paste("Basic", secret),
"Content-Type" = "application/x-www-form-urlencoded;charset=UTF-8"
),
Expand All @@ -355,22 +358,21 @@ token <- paste("Bearer", content(req)$access_token)

#Actual API call
url <- "https://api.twitter.com/1.1/statuses/user_timeline.json?count=10&screen_name=Rbloggers"
req <- GET(url, add_headers(Authorization = token))
json <- content(req, as = "text")
req <- httr::GET(url, add_headers(Authorization = token))
json <- httr::content(req, as = "text")
tweets <- fromJSON(json)
substring(tweets$text, 1, 100)
```

```
[1] "Analysing longitudinal data: Multilevel growth models (II) http://t.co/unUxszG7VJ #rstats"
[2] "RcppDE 0.1.4 http://t.co/3qPhFzoOpj #rstats"
[3] "Minimalist Maps http://t.co/fpkNznuCoX #rstats"
[4] "Tutorials freely available of course I taught: including ggplot2, dplyr and shiny http://t.co/WsxX4U"
[5] "Deploying Shiny apps with shinyapps.io http://t.co/tjef1pbKLt #rstats"
[6] "Bootstrap Evaluation of Clusters http://t.co/EbY7ziKCz5 #rstats"
[7] "Add external code to Rmarkdown http://t.co/RCJEmS8gyP #rstats"
[8] "Linear models with weighted observations http://t.co/pUoHpvxAGC #rstats"
[9] "dplyr 0.4.3 http://t.co/ze3zc8t7qj #rstats"
[10] "xkcd survey and the power to shape the internet http://t.co/vNaKhxWxE4 #rstats"
[1] "Rblpapi 0.3.4 https://t.co/NoGluTGSld #rstats #DataScience"
[2] "Introducing DohaR – A new R User Group in Doha, Qatar https://t.co/MWSKgMap9I #rstats #DataScience"
[3] "FSA v0.8.7 Released https://t.co/2nnGMGINA7 #rstats #DataScience"
[4] "Too Much Parallelism is as Bad https://t.co/t0RffUvLYs #rstats #DataScience"
[5] "Coming up: principal components analysis https://t.co/f9dUnhuC9n #rstats #DataScience"
[6] "Shiny Apps Gallery using Plotly in R https://t.co/cEFvgy1VPY #rstats #DataScience"
[7] "Who is going down? Bundesliga Betting Odds – updated https://t.co/uvpcmOmcaf #rstats #DataScience"
[8] "BH 1.60.0-2 https://t.co/kZHVjPzG65 #rstats #DataScience"
[9] "Red herring bites https://t.co/IJQwBQkImx #rstats #DataScience"
[10] "R Tools for Visual Studio 3.0 now available https://t.co/JWKthTwEnC #rstats #DataScience"
```

244 changes: 152 additions & 92 deletions inst/doc/json-apis.html

Large diffs are not rendered by default.

Binary file modified inst/doc/json-opencpu.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion inst/doc/json-paging.Rmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Combining pages of JSON data with jsonlite"
date: "2015-09-06"
date: "2016-05-09"
output:
html_document
vignette: >
Expand Down
85 changes: 71 additions & 14 deletions inst/doc/json-paging.html

Large diffs are not rendered by default.

Loading

0 comments on commit 64f6a96

Please sign in to comment.