Skip to content

Commit

Permalink
version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jrnold authored and cran-robot committed Jul 16, 2014
1 parent c45dd24 commit 6ee9cbd
Show file tree
Hide file tree
Showing 21 changed files with 350 additions and 349 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
@@ -1,14 +1,14 @@
Package: pollstR
Title: R client for the Huffpost Pollster API
Description: An R interface to the Huffington Post Pollster API, which provides
a programmatic interface to political polls.
Version: 1.0-0
Date: 2014-5-1
programmatic interface to political polls.
Version: 1.0.1
Date: 2014-7-15
Authors@R: c(person("Jeffrey B.", "Arnold", email = "jeffrey.arnold@gmail.com",
role = c("aut", "cre")),
person("Thomas J.", "Leeper", role = c("aut"),
email = "thosjleeper@gmail.com"))
Depends: R (>= 3.1.0)
Depends: R (>= 3.0.3)
Imports: httr, plyr, jsonlite
Suggests: knitr, dplyr, ggplot2, testthat
URL: https://github.com/rOpenGov/pollstR
Expand All @@ -17,10 +17,10 @@ VignetteBuilder: knitr
License: GPL-2
LazyLoad: yes
LazyData: true
Packaged: 2014-05-01 17:49:33 UTC; jrnold
Packaged: 2014-07-15 18:58:20 UTC; jrnold
Author: Jeffrey B. Arnold [aut, cre],
Thomas J. Leeper [aut]
Maintainer: Jeffrey B. Arnold <jeffrey.arnold@gmail.com>
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2014-05-02 07:13:22
Date/Publication: 2014-07-16 01:11:21
38 changes: 20 additions & 18 deletions MD5
@@ -1,29 +1,31 @@
eda56aad95925d621512cf631ff52303 *DESCRIPTION
040fc92906c26d5dfa54e015168de5f8 *NAMESPACE
bb887c580e136edcdd247184967d7dcd *R/chart.R
3c77bd0c693940531d78bcb52eeb78c9 *R/charts.R
d724e54cae52d2b345315aa2cdf49600 *DESCRIPTION
4687139c0b9f9859d82e5330d52e0cdf *NAMESPACE
7580829f48b37eb33681ce4d8e3ea972 *NEWS
e76d0a794846ce56a1c0f09ac8f8207f *R/chart.R
c87e7e75183bcd5888fba226696ca63d *R/charts.R
9a28f562f385a8414e4e93ddd34f8fe8 *R/polls.R
75e154245af26efcd54c8ff18db9b187 *R/pollstR-package.R
e79a08b136137565e7eca6fd4452ad37 *R/pollstR-package.R
45ba0c59aee92f32e4a9ed2f95daf706 *build/vignette.rds
d8943e822fc0b8c583b724e194f7be1c *inst/CITATION
fa9c5e87e61e52f98f7dc586534ead82 *inst/doc/introduction.Rmd
c8b791256e8afecdebd2adbc48d8008d *inst/doc/introduction.html
588259661673aeb266869351eec20c48 *inst/doc/introduction.Rmd
03b1f95bf7329530bcd9355247425271 *inst/doc/introduction.html
f3f501d20202935c36d51f868f982718 *inst/vign/children/api-overview.Rmd
fe1a7f779e4ca6009ba9529f2643a5db *inst/vign/children/example-obamas-approval.Rmd
de3824448e393a231987a1e00682b0f3 *inst/vign/children/install.Rmd
9285bf6585647db9adea3c7e44135bc5 *inst/vign/children/install.Rmd
9b1e2743cfc498ba528be67e96793bd4 *inst/vign/children/intro.Rmd
6944ce15eb429591f7fdffbf78ff062e *inst/vign/figures/obama-favorable-chart-2.png
9b9e2055acccd8723e76ee36ec966c1d *inst/vign/figures/obama-favorable-chart.png
879a81248680d02b54c89e46fbf4c943 *inst/vign/children/introduction.md
0c365c018d0cdf1181b850644058a583 *inst/vign/figures/obama-favorable-chart-2.png
637b4a7e9867d93724ca3a4b2e4e16c1 *inst/vign/figures/obama-favorable-chart.png
32128653990d13448056e2c6017fa2bf *inst/vign/introduction.Rmd
1d2f6dfcb54714ca4ff31a9bde3967f8 *inst/vign/introduction.md
c68e8bda4c830d1313134f7a0a76b22e *man/pollstR.Rd
99c6073caf8e2c7642912bcc90ac37d1 *man/pollstr_chart.Rd
4f53f755d938d87ac0918a687883ebcf *man/pollstr_charts.Rd
b9d5e65202118c11da012ca127bc0653 *man/pollstr_polls.Rd
af2581d96b06b077db86955b0bee3eb5 *inst/vign/introduction.md
dd1fe7df581aed4dd28420b403519a4d *man/pollstR.Rd
ca93f607763ff58d36ab426784913df1 *man/pollstr_chart.Rd
d33970c1e931e91c2b985ce1f6e0a1b8 *man/pollstr_charts.Rd
53b0ad66fa9c605f5b15b70ab3a8cc81 *man/pollstr_polls.Rd
29b0f8aa2f27daa9c17f61e03e190f10 *tests/testthat.R
8693fd5b51c1f99fa1acf655d32058f6 *tests/testthat/test-chart.R
4300f52460314224f3df9b3c1b74b224 *tests/testthat/test-charts.R
faefe3ba44af8ad06f424f22f8f883d7 *tests/testthat/test-polls.R
6944ce15eb429591f7fdffbf78ff062e *vignettes/assets/obama-favorable-chart-2.png
9b9e2055acccd8723e76ee36ec966c1d *vignettes/assets/obama-favorable-chart.png
fa9c5e87e61e52f98f7dc586534ead82 *vignettes/introduction.Rmd
0c365c018d0cdf1181b850644058a583 *vignettes/assets/obama-favorable-chart-2.png
637b4a7e9867d93724ca3a4b2e4e16c1 *vignettes/assets/obama-favorable-chart.png
588259661673aeb266869351eec20c48 *vignettes/introduction.Rmd
2 changes: 2 additions & 0 deletions NAMESPACE
@@ -1,3 +1,5 @@
# Generated by roxygen2 (4.0.1): do not edit by hand

S3method(print,pollstr_chart)
S3method(print,pollstr_charts)
export(pollstr_chart)
Expand Down
20 changes: 20 additions & 0 deletions NEWS
@@ -0,0 +1,20 @@
# pollstR 1.0.1

* Bugfix: did not convert some election date fields

# pollstR 1.0.0

* submit to CRAN

# pollstR 0.2.0

Merge with http://github.com/jrnold/pollster. This is a complete rewrite of the client.

* ``getchart`` replaced with ``pollstr_charts``. Returns class ``pollstr_charts``.
* ``getchart`` replaced with ``pollstr_chart``. Returns class ``pollstr_chart``.
* ``getpolls`` replaced with ``pollstr_polls``. Returns class ``pollstr_polls``.
* ``xml`` API access no longer available.

# pollstR 0.1

* Initial package release
7 changes: 3 additions & 4 deletions R/chart.R
Expand Up @@ -9,9 +9,7 @@ pollstr_chart_url <- function(slug) {
# clean up the objects returned by the API
pollstr_chart_parse <- function(.data) {
# Convert
.data[["election_date"]] <-
as.Date(electiondate2date(.data[["election_date"]]),
"%Y-%m-%d")
.data[["election_date"]] <- electiondate2date(.data[["election_date"]])
.data[["last_updated"]] <-
as.POSIXct(.data[["last_updated"]],
format = "%Y-%m-%dT%H:%M:%SZ",
Expand Down Expand Up @@ -65,7 +63,8 @@ pollstr_chart_parse <- function(.data) {
#' \item \code{title}
#' \item \code{slug}
#' \item \code{topic}
#' \item \code{short_title}

#' #' \item \code{short_title}
#' \item \code{poll_count}
#' \item \code{last_updated}
#' \item \code{url}
Expand Down
4 changes: 1 addition & 3 deletions R/charts.R
Expand Up @@ -23,9 +23,7 @@ charts2df <- function(.data) {
if (is.null(x[["topic"]])) {
x[["topic"]] <- ""
}
x[["election_date"]] <-
as.Date(electiondate2date(x[["election_date"]]),
"%Y-%m-%d")
x[["election_date"]] <- electiondate2date(x[["election_date"]])
as.data.frame(x)
})
# Convert
Expand Down
4 changes: 2 additions & 2 deletions R/pollstR-package.R
Expand Up @@ -32,8 +32,8 @@ convert_df <- function(x) {
# election date entry
electiondate2date <- function(x) {
if (is.null(x)) {
NA_character_
as.Date(NA_character_)
} else {
sprintf("%d-%d-%d", x$year, x$month, x$day)
as.Date(x, "%Y-%m-%d")
}
}
97 changes: 45 additions & 52 deletions inst/doc/introduction.Rmd
Expand Up @@ -53,15 +53,15 @@ str(charts)
#> ..$ poll_count : int [1:444] 65 55 44 59 10 34 19 258 589 300 ...
#> ..$ last_updated : POSIXct[1:444], format: "2012-01-02 13:08:44" ...
#> ..$ url : chr [1:444] "http://elections.huffingtonpost.com/pollster/2012-iowa-gop-primary" "http://elections.huffingtonpost.com/pollster/2012-new-hampshire-gop-primary" "http://elections.huffingtonpost.com/pollster/2012-south-carolina-gop-primary" "http://elections.huffingtonpost.com/pollster/2012-florida-gop-primary" ...
#> $ estimates:'data.frame': 1051 obs. of 8 variables:
#> ..$ choice : chr [1:1051] "Romney" "Paul" "Santorum" "Gingrich" ...
#> ..$ value : num [1:1051] 22.5 21.3 15.9 12.6 11.1 8.3 3.7 5.9 0.9 39.6 ...
#> ..$ lead_confidence: num [1:1051] NA NA NA NA NA NA NA NA NA NA ...
#> ..$ first_name : chr [1:1051] "Mitt" "Ron" "Rick" "Newt" ...
#> ..$ last_name : chr [1:1051] "Romney" "Paul" "Santorum" "Gingrich" ...
#> $ estimates:'data.frame': 1048 obs. of 8 variables:
#> ..$ choice : chr [1:1048] "Romney" "Paul" "Santorum" "Gingrich" ...
#> ..$ value : num [1:1048] 22.5 21.3 15.9 12.6 11.1 8.3 3.7 5.9 0.9 39.6 ...
#> ..$ lead_confidence: num [1:1048] NA NA NA NA NA NA NA NA NA NA ...
#> ..$ first_name : chr [1:1048] "Mitt" "Ron" "Rick" "Newt" ...
#> ..$ last_name : chr [1:1048] "Romney" "Paul" "Santorum" "Gingrich" ...
#> ..$ party : Factor w/ 6 levels "Dem","Gre","ind",..: 6 6 6 6 6 6 6 NA NA 6 ...
#> ..$ incumbent : logi [1:1051] FALSE FALSE FALSE FALSE FALSE FALSE ...
#> ..$ slug : chr [1:1051] "2012-iowa-gop-primary" "2012-iowa-gop-primary" "2012-iowa-gop-primary" "2012-iowa-gop-primary" ...
#> ..$ incumbent : logi [1:1048] FALSE FALSE FALSE FALSE FALSE FALSE ...
#> ..$ slug : chr [1:1048] "2012-iowa-gop-primary" "2012-iowa-gop-primary" "2012-iowa-gop-primary" "2012-iowa-gop-primary" ...
#> - attr(*, "class")= chr "pollstr_charts"
```

Expand Down Expand Up @@ -92,31 +92,24 @@ print(obama_favorable)
#> Chart Slug: obama-favorable-rating
#> Topic: favorable-ratings
#> State: 1
#> Polls: 805
#> Polls: 807
#> Updated: 1.399e+09
#> URL: http://elections.huffingtonpost.com/pollster/obama-favorable-rating
#> Estimates:
#> choice value lead_confidence first_name last_name party
#> 1 Favorable 45.6 NA <NA> <NA> <NA>
#> 2 Unfavorable 48.5 NA <NA> <NA> <NA>
#> 3 Undecided 4.1 NA <NA> <NA> <NA>
#> 4 Neutral 12.6 NA <NA> <NA> <NA>
#> 5 Not Heard Enough 0.2 NA <NA> <NA> <NA>
#> incumbent
#> 1 NA
#> 2 NA
#> 3 NA
#> 4 NA
#> 5 NA
#> choice value lead_confidence first_name last_name party incumbent
#> 1 Favorable 45.9 NA <NA> <NA> <NA> NA
#> 2 Unfavorable 48.5 NA <NA> <NA> <NA> NA
#> 3 Undecided 4.0 NA <NA> <NA> <NA> NA
#> 4 Neutral 12.6 NA <NA> <NA> <NA> NA
#>
#> First 6 (of 2127) daily estimates:
#> First 6 (of 2130) daily estimates:
#> choice value date
#> 1 Undecided 4.1 2014-04-27
#> 2 Neutral 12.6 2014-04-27
#> 3 Unfavorable 48.5 2014-04-27
#> 4 Favorable 45.6 2014-04-27
#> 5 Undecided 4.1 2014-04-21
#> 6 Unfavorable 48.6 2014-04-21
#> 1 Favorable 45.9 2014-04-28
#> 2 Undecided 4.0 2014-04-28
#> 3 Unfavorable 48.5 2014-04-28
#> 4 Favorable 45.9 2014-04-27
#> 5 Undecided 4.0 2014-04-27
#> 6 Unfavorable 48.5 2014-04-27
```

The slug can be found from the results of a ``pollstr_charts`` query.
Expand Down Expand Up @@ -149,31 +142,31 @@ str(obama_favorable_polls)

```
#> List of 2
#> $ polls :'data.frame': 16 obs. of 9 variables:
#> ..$ id : int [1:16] 19357 19316 19256 19261 19252 19239 19169 19132 19137 19172 ...
#> ..$ pollster : Factor w/ 8 levels "NBC/WSJ","YouGov/Economist",..: 1 2 3 2 4 2 2 2 5 6 ...
#> ..$ start_date : Date[1:16], format: "2014-04-23" ...
#> ..$ end_date : Date[1:16], format: "2014-04-27" ...
#> ..$ method : Factor w/ 2 levels "Phone","Internet": 1 2 1 2 1 2 2 2 2 1 ...
#> ..$ source : chr [1:16] "http://msnbcmedia.msn.com/i/MSNBC/Sections/A_Politics/14271_APRIL_NBC_WSJ_Poll.pdf" "http://d25d2506sfb94s.cloudfront.net/cumulus_uploads/document/lx2kkwdvcu/econToplines.pdf" "http://www.foxnews.com/politics/interactive/2014/04/21/fox-news-poll-independents-more-likely-to-back-anti-obamacare-candidates"| __truncated__ "http://d25d2506sfb94s.cloudfront.net/cumulus_uploads/document/8cnxcwv20i/econToplines.pdf" ...
#> ..$ last_updated : POSIXct[1:16], format: "2014-04-30 20:01:58" ...
#> ..$ survey_houses: chr [1:16] "" "" "" "" ...
#> ..$ sponsors : chr [1:16] "" "" "" "" ...
#> $ questions:'data.frame': 1042 obs. of 14 variables:
#> ..$ question : Factor w/ 33 levels "2014 National House Race",..: 1 1 1 2 2 2 2 3 3 3 ...
#> ..$ chart : Factor w/ 31 levels "2014-national-house-race",..: 1 1 1 31 31 31 31 21 21 21 ...
#> ..$ topic : Factor w/ 7 levels "","2014-house",..: 2 2 2 1 1 1 1 7 7 7 ...
#> $ polls :'data.frame': 18 obs. of 9 variables:
#> ..$ id : int [1:18] 19367 19357 19316 19256 19261 19372 19252 19239 19169 19132 ...
#> ..$ pollster : Factor w/ 9 levels "YouGov/Economist",..: 1 2 1 3 1 4 5 1 1 1 ...
#> ..$ start_date : Date[1:18], format: "2014-04-26" ...
#> ..$ end_date : Date[1:18], format: "2014-04-28" ...
#> ..$ method : Factor w/ 3 levels "Internet","Phone",..: 1 2 1 2 1 3 2 1 1 1 ...
#> ..$ source : chr [1:18] "http://d25d2506sfb94s.cloudfront.net/cumulus_uploads/document/boljc6ah6k/econToplines.pdf" "http://msnbcmedia.msn.com/i/MSNBC/Sections/A_Politics/14271_APRIL_NBC_WSJ_Poll.pdf" "http://d25d2506sfb94s.cloudfront.net/cumulus_uploads/document/lx2kkwdvcu/econToplines.pdf" "http://www.foxnews.com/politics/interactive/2014/04/21/fox-news-poll-independents-more-likely-to-back-anti-obamacare-candidates"| __truncated__ ...
#> ..$ last_updated : POSIXct[1:18], format: "2014-05-02 16:05:38" ...
#> ..$ survey_houses: chr [1:18] "" "" "" "" ...
#> ..$ sponsors : chr [1:18] "" "" "" "" ...
#> $ questions:'data.frame': 1150 obs. of 14 variables:
#> ..$ question : Factor w/ 33 levels "US Right Direction Wrong Track",..: 1 1 1 2 2 2 2 2 3 3 ...
#> ..$ chart : Factor w/ 31 levels "2014-national-house-race",..: 31 31 31 16 16 16 16 16 20 20 ...
#> ..$ topic : Factor w/ 7 levels "","2014-house",..: 1 1 1 6 6 6 6 6 6 6 ...
#> ..$ state : Factor w/ 1 level "US": 1 1 1 1 1 1 1 1 1 1 ...
#> ..$ subpopulation : Factor w/ 12 levels "Registered Voters",..: 1 1 1 2 2 2 2 2 2 2 ...
#> ..$ observations : int [1:1042] NA NA NA 1000 1000 1000 1000 1000 1000 1000 ...
#> ..$ margin_of_error: num [1:1042] NA NA NA 3.1 3.1 3.1 3.1 3.1 3.1 3.1 ...
#> ..$ choice : chr [1:1042] "Democrat" "Republican" "Undecided" "Right Direction" ...
#> ..$ value : num [1:1042] 45 45 10 27 63 6 4 44 50 6 ...
#> ..$ first_name : chr [1:1042] NA NA NA NA ...
#> ..$ last_name : chr [1:1042] NA NA NA NA ...
#> ..$ party : Factor w/ 3 levels "Dem","ind","Rep": 1 3 NA NA NA NA NA NA NA NA ...
#> ..$ incumbent : logi [1:1042] FALSE FALSE NA NA NA NA ...
#> ..$ id : int [1:1042] 19357 19357 19357 19357 19357 19357 19357 19357 19357 19357 ...
#> ..$ subpopulation : Factor w/ 12 levels "Adults","Adults - Democrat",..: 1 1 1 1 1 1 1 1 1 1 ...
#> ..$ observations : int [1:1150] 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 ...
#> ..$ margin_of_error: num [1:1150] 4.3 4.3 4.3 4.3 4.3 4.3 4.3 4.3 4.3 4.3 ...
#> ..$ choice : chr [1:1150] "Right Direction" "Wrong Track" "Undecided" "Don't know" ...
#> ..$ value : num [1:1150] 32 58 11 39 19 15 9 17 26 24 ...
#> ..$ first_name : chr [1:1150] NA NA NA NA ...
#> ..$ last_name : chr [1:1150] NA NA NA NA ...
#> ..$ party : Factor w/ 3 levels "Dem","ind","Rep": NA NA NA NA NA NA NA NA NA NA ...
#> ..$ incumbent : logi [1:1150] NA NA NA NA NA NA ...
#> ..$ id : int [1:1150] 19367 19367 19367 19367 19367 19367 19367 19367 19367 19367 ...
#> - attr(*, "class")= chr "pollstr_polls"
```

Expand Down

0 comments on commit 6ee9cbd

Please sign in to comment.