From 61e7f194db4a26382e04ee70e48c423e1c47b55e Mon Sep 17 00:00:00 2001 From: dmpe Date: Thu, 23 Jul 2015 22:20:42 +0200 Subject: [PATCH] add geojson example & vignette (dependencies are suggested, later to be moved to required) should fix travis now fix again second time the same. give up give up on travis. wont work ? --- .gitignore | 1 + .travis.yml | 8 ++++++ CONTRIBUTING.md | 1 - DESCRIPTION | 12 ++++++--- NEWS.md | 4 ++- R/geo.R | 11 -------- README.md | 28 ++----------------- RSocrata.Rproj | 2 +- vignettes/Examples.Rmd | 61 ++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 84 insertions(+), 44 deletions(-) delete mode 100644 R/geo.R create mode 100644 vignettes/Examples.Rmd diff --git a/.gitignore b/.gitignore index dccab3c..74f359c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ *.Rproj.user *.Rhistory .Rproj.user +inst/doc diff --git a/.travis.yml b/.travis.yml index d9a0eb2..e2cef62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,12 +8,20 @@ language: R sudo: required warnings_are_errors: true +before_install: + - sudo apt-get install libv8-dev + r_github_packages: - hadley/httr - jeroenooms/jsonlite - jeroenooms/curl - klutometis/roxygen - jimhester/covr + - ropensci/geojsonio + +r_binary_packages: + - rgdal + - rgeos after_success: - Rscript -e 'library(covr);coveralls()' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d627bf5..7e08838 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,3 @@ - # How to contribute We really appreciate when users [fix bugs](https://github.com/Chicago/RSocrata/pull/25) or [provide new features](https://github.com/Chicago/RSocrata/pull/21). When submitting changes, please read below to help the development team keep on top of issues and changes. diff --git a/DESCRIPTION b/DESCRIPTION index e85496b..28ee7ec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,15 +13,19 @@ Version: 1.6.3 Date: 2015-07-23 Author: Hugh Devlin, Ph. D., Tom Schenk, Jr., and John Malc Maintainer: "Tom Schenk Jr." -Depends: +Depends: R (>= 3.0.0) -Imports: +Imports: httr (>= 1.0.0), jsonlite (>= 0.9.16), mime (>= 0.3) -Suggests: +Suggests: testthat (>= 0.10.0), - roxygen2 (>= 4.1.0) + roxygen2 (>= 4.1.0), + knitr (>= 1.10.5), + leaflet (>= 1.0.0), + geojsonio (>= 0.1.0) License: MIT + file LICENSE URL: https://github.com/Chicago/RSocrata BugReports: https://github.com/Chicago/RSocrata/issues +VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index a4fafee..d68cdd2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -38,8 +38,10 @@ Deprecated ```httr::guess_media()``` and implemented ```mime::guess_type()``` * Migrate Travis-CI to "proper" R YAML ([#46](https://github.com/Chicago/RSocrata/issues/46)) +### 1.6.3 / 1.6.2 ??? (see roadmap) - +* Add a small vignette with examples +* Mostly internal changes which should not influence the current behaviour ([#53](https://github.com/Chicago/RSocrata/pull/53)) diff --git a/R/geo.R b/R/geo.R deleted file mode 100644 index 8059a6c..0000000 --- a/R/geo.R +++ /dev/null @@ -1,11 +0,0 @@ -library(leaflet) -library(geojsonio) - - -asdsadas <- geojson_read("https://data.cityofchicago.org/resource/6zsd-86xi.geojson", method = "local", parse = FALSE, what = "list") - -m <- leaflet() %>% - addGeoJSON(asdsadas) %>% - setView(-87.6, 41.8, zoom = 10) %>% addTiles() -m - diff --git a/README.md b/README.md index 0be6854..48e19b5 100644 --- a/README.md +++ b/README.md @@ -52,33 +52,9 @@ install.packages("rgdal") install.packages("rgeos") ``` -### Example: Reading SoDA valid URLs -```r -earthquakesDataFrame <- read.socrata("http://soda.demo.socrata.com/resource/4334-bgaj.csv") -nrow(earthquakesDataFrame) # 1007 (two "pages") -class(earthquakesDataFrame$Datetime[1]) # POSIXlt -``` - -### Example: Reading "human-readable" URLs -```r -earthquakesDataFrame <- read.socrata("https://soda.demo.socrata.com/dataset/USGS-Earthquakes-for-2012-11-01-API-School-Demo/4334-bgaj") -nrow(earthquakesDataFrame) # 1007 (two "pages") -class(earthquakesDataFrame$Datetime[1]) # POSIXlt -``` +### Examples -### Example: Using API key to read datasets -```r -token <- "ew2rEMuESuzWPqMkyPfOSGJgE" -earthquakesDataFrame <- read.socrata("http://soda.demo.socrata.com/resource/4334-bgaj.csv", app_token = token) -nrow(earthquakesDataFrame) -``` - -### Example: List all datasets on portal -```r -allSitesDataFrame <- ls.socrata("https://soda.demo.socrata.com") -nrow(allSitesDataFrame) # Number of datasets -allSitesDataFrame$title # Names of each dataset -``` +Look in the `vignette` folder ### Issues diff --git a/RSocrata.Rproj b/RSocrata.Rproj index 584b854..c9f9fb2 100644 --- a/RSocrata.Rproj +++ b/RSocrata.Rproj @@ -9,7 +9,7 @@ UseSpacesForTab: Yes NumSpacesForTab: 2 Encoding: UTF-8 -RnwWeave: Sweave +RnwWeave: knitr LaTeX: pdfLaTeX BuildType: Package diff --git a/vignettes/Examples.Rmd b/vignettes/Examples.Rmd new file mode 100644 index 0000000..55d7f40 --- /dev/null +++ b/vignettes/Examples.Rmd @@ -0,0 +1,61 @@ +--- +title: "Vignette for RSocrata" +author: "Developers of the City of Chicago (USA)" +date: "`r Sys.Date()`" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Vignette Title} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r} +library(RSocrata) + +# for geo support +library(leaflet) +library(geojsonio) +``` + +### Example: Reading SoDA valid URLs +```{r} +earthquakesDataFrame <- read.socrata("http://soda.demo.socrata.com/resource/4334-bgaj.csv") +nrow(earthquakesDataFrame) # 1007 (two "pages") +class(earthquakesDataFrame$Datetime[1]) # POSIXlt +``` + +### Example: Reading "human-readable" URLs +```{r} +earthquakesDataFrame <- read.socrata("https://soda.demo.socrata.com/dataset/USGS-Earthquakes-for-2012-11-01-API-School-Demo/4334-bgaj") +nrow(earthquakesDataFrame) # 1007 (two "pages") +class(earthquakesDataFrame$Datetime[1]) # POSIXlt +``` + +### Example: Using API key to read datasets +```{r} +token <- "ew2rEMuESuzWPqMkyPfOSGJgE" +earthquakesDataFrame <- read.socrata("http://soda.demo.socrata.com/resource/4334-bgaj.csv", app_token = token) +nrow(earthquakesDataFrame) +``` + +### Example: List all datasets on portal +```{r} +allSitesDataFrame <- ls.socrata("https://soda.demo.socrata.com") +nrow(allSitesDataFrame) # Number of datasets +allSitesDataFrame$title # Names of each dataset +``` + +### Geo & Leaflet + +```{r} + +asdsadas <- geojson_read("https://data.cityofchicago.org/resource/6zsd-86xi.geojson", method = "local", parse = FALSE, what = "list") + +m <- leaflet() %>% + addGeoJSON(asdsadas) %>% + setView(-87.6, 41.8, zoom = 10) %>% + addTiles() +m + +``` +