浏览代码

Census region dataset

pull/4/head
Bob Rudis 9 年前
父节点
当前提交
da41a43f4e
  1. 22
      R/datasets.r
  2. 3
      README.Rmd
  3. 4
      README.md
  4. 13
      crunch/mkdata.r
  5. 二进制
      data/census_regions.rda
  6. 2
      man/cdcfluview.Rd
  7. 28
      man/census_regions.Rd
  8. 2
      man/hhs_regions.Rd

22
R/datasets.r

@ -1,5 +1,5 @@
#' @title HHS Region Table
#' @description This dataset contains the names, numbers, regional offices for
#' @description This dataset contains the names, numbers, regional offices for-,
#' and states/territories belonging to the (presently) 10 HHS U.S.
#' regions in "long" format. It consists of a \code{data.frame}
#' with the following columns:
@ -19,4 +19,24 @@
#' @usage data(hhs_regions)
#' @note Last updated 2015-08-09.
#' @format A data frame with 59 rows and 4 variables
NULL
#' @title Census Region Table
#' @description This dataset contains the states belonging to the (presently) 4
#' U.S. Census regions in "long" format. It consists of a \code{data.frame}
#' with the following columns:
#'
#' \itemize{
#' \item \code{region}: the official Census region name (e.g. "\code{East}")
#' \item \code{state}: state belonging to the region
#' }
#'
#' @docType data
#' @keywords datasets
#' @name census_regions
#'
#' @references \url{http://www.cdc.gov/std/stats12/images/CensusMap.png}
#' @usage data(census_regions)
#' @note Last updated 2015-08-09.
#' @format A data frame with 51 rows and 2 variables
NULL

3
README.Rmd

@ -34,10 +34,11 @@ The following functions are implemented:
The following data sets are included:
- `hhs_regions` HHS Region Table (a data frame with 59 rows and 4 variables)
- `census_regions` Census Region Table (a data frame with 51 rows and 2 variables)
### News
- Version 0.4.0.999 released : another fix for the CDC API (for region parameter); added data file for region lookups; added weekly high-level flu report retrieval
- Version 0.4.0.999 released : another fix for the CDC API (for region parameter); added data files for HHS/Census region lookups; added weekly high-level flu report retrieval
- Version 0.3 released : fix for the CDC API (it changed how year & region params are encoded in the request)
- Version 0.2.1 released : bumped up `httr` version # requirement in `DESCRIPTION` (via Issue [1](https://github.com/hrbrmstr/cdcfluview/issues/1))
- Version 0.2 released : added state-level data retrieval

4
README.md

@ -15,10 +15,12 @@ The following functions are implemented:
The following data sets are included:
- `hhs_regions` HHS Region Table (a data frame with 59 rows and 4 variables)
- `census_regions` Census Region Table (a data frame with 51 rows and 2 variables)
### News
- Version 0.4.0.999 released : another fix for the CDC API (for region parameter); added data file for region lookups; added weekly high-level flu report retrieval
- Version 0.4.0.999 released : another fix for the CDC API (for region parameter); added data files for HHS/Census region lookups; added weekly high-level flu report retrieval
- Version 0.3 released : fix for the CDC API (it changed how year & region params are encoded in the request)
- Version 0.2.1 released : bumped up `httr` version \# requirement in `DESCRIPTION` (via Issue [1](https://github.com/hrbrmstr/cdcfluview/issues/1))
- Version 0.2 released : added state-level data retrieval

13
crunch/mkdata.r

@ -23,4 +23,15 @@ do.call(rbind.data.frame, lapply(1:nrow(hhs_regions), function(i) {
str(hhs_regions)
devtools::use_data(hhs_regions, overwrite=TRUE)
library(rvest)
library(magrittr)
pg <- html("http://www.cdc.gov/std/stats11/census.htm")
pg %>% html_table() %>% extract2(1) %>% as.list -> cens
do.call(rbind.data.frame, lapply(names(cens), function(x) {
data.frame(region=x,
state=cens[[x]][cens[[x]]!=""],
stringsAsFactors=FALSE)
})) -> census_regions
devtools::use_data(hhs_regions, census_regions, overwrite=TRUE)

二进制
data/census_regions.rda

二进制文件未显示。

2
man/cdcfluview.Rd

@ -1,5 +1,5 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/cdcfluview-package.R
% Please edit documentation in R/cdcfluview-package.r
\docType{package}
\name{cdcfluview}
\alias{cdcfluview}

28
man/census_regions.Rd

@ -0,0 +1,28 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/datasets.r
\docType{data}
\name{census_regions}
\alias{census_regions}
\title{Census Region Table}
\format{A data frame with 51 rows and 2 variables}
\usage{
data(census_regions)
}
\description{
This dataset contains the states belonging to the (presently) 4
U.S. Census regions in "long" format. It consists of a \code{data.frame}
with the following columns:
\itemize{
\item \code{region}: the official Census region name (e.g. "\code{East}")
\item \code{state}: state belonging to the region
}
}
\note{
Last updated 2015-08-09.
}
\references{
\url{http://www.cdc.gov/std/stats12/images/CensusMap.png}
}
\keyword{datasets}

2
man/hhs_regions.Rd

@ -9,7 +9,7 @@
data(hhs_regions)
}
\description{
This dataset contains the names, numbers, regional offices for
This dataset contains the names, numbers, regional offices for-,
and states/territories belonging to the (presently) 10 HHS U.S.
regions in "long" format. It consists of a \code{data.frame}
with the following columns:

正在加载...
取消
保存