diff --git a/.Rbuildignore b/.Rbuildignore index 749f513..9483e43 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,2 +1,5 @@ ^LICENSE\.md$ ^data-raw$ +^README\.Rmd$ +^codecov\.yml$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..0f2fe08 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,52 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..fefc52e --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,61 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: test-coverage + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + covr::to_cobertura(cov) + shell: Rscript {0} + + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} + file: ./cobertura.xml + plugin: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/DESCRIPTION b/DESCRIPTION index f1ed01b..e8d2ec2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,4 +19,5 @@ Imports: jsonlite, utils, DBI, - duckdb + duckdb, + stringi diff --git a/NAMESPACE b/NAMESPACE index 12390a0..b7485dc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,3 +7,4 @@ export(get_nbm_available) export(get_nbm_release) import(DBI) import(duckdb) +importFrom(stringi,stri_pad_left) diff --git a/R/check_frn.R b/R/check_frn.R index b97eff8..9a86700 100644 --- a/R/check_frn.R +++ b/R/check_frn.R @@ -5,11 +5,13 @@ #' @return a table with info on FRN #' @export #' +#' @importFrom stringi stri_pad_left +#' #' @examples #' check_frn(8181448) check_frn <- function(frn) { - frn_pad <- sprintf("%010s", frn) + frn_pad <- stringi::stri_pad_left(frn, width = 10, pad = "0") filter <- cori.data.fcc::fcc_provider[["frn"]] %in% frn_pad dat <- cori.data.fcc::fcc_provider[filter, ] return(dat) diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..27f2966 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,73 @@ +--- +output: github_document +--- + + + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-", + out.width = "100%" +) +``` + +# cori.data.fcc + + +[![Codecov test coverage](https://codecov.io/gh/ruralinnovation/cori.data.fcc/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ruralinnovation/cori.data.fcc?branch=main) +[![R-CMD-check](https://github.com/ruralinnovation/cori.data.fcc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ruralinnovation/cori.data.fcc/actions/workflows/R-CMD-check.yaml) + + +The goal of cori.data.fcc is to facilate the discovery, the download and the use of FCC's National Broadband Map [(NBM)](https://broadbandmap.fcc.gov/home) data. + +## Installation + +You can install the development version of cori.data.fcc from [GitHub](https://github.com/) with: + +``` r +# install.packages("devtools") +devtools::install_github("ruralinnovation/cori.data.fcc") +``` + +## Example + +This is a basic example which shows some basic workflow: + +```{r example-release} +library(cori.data.fcc) + +release <- get_nbm_release() # get the available releases +release +``` + +You can also inspect what is available: + +```{r example-available} +nbm <- get_nbm_available() # get what data is available +# if we are intrested in "Fixed Broadband" / "Nationwide" / released "June 30, 2023" +nbm_filter <- nbm[which(nbm$release == "June 30, 2023" & + nbm$data_type == "Fixed Broadband" & + nbm$data_category == "Nationwide"), ] +rownames(nbm_filter) <- NULL + + +# or +nbm_dplyr_filter <- nbm |> dplyr::filter(release == "June 30, 2023" & + data_type == "Fixed Broadband" & + data_category == "Nationwide") +all.equal(nbm_filter, nbm_dplyr_filter) +head(nbm_filter) +``` + + +The package also provide the list of Provider ID and FRN + +```{r fcc_provider} +str(fcc_provider) +``` + +## Inspiration + +This package was imspired by https://github.com/bbcommons/bfm-explorer diff --git a/README.md b/README.md new file mode 100644 index 0000000..e1029d2 --- /dev/null +++ b/README.md @@ -0,0 +1,101 @@ + + + +# cori.data.fcc + + + +[![Codecov test +coverage](https://codecov.io/gh/ruralinnovation/cori.data.fcc/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ruralinnovation/cori.data.fcc?branch=main) +[![R-CMD-check](https://github.com/ruralinnovation/cori.data.fcc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ruralinnovation/cori.data.fcc/actions/workflows/R-CMD-check.yaml) + + +The goal of cori.data.fcc is to facilate the discovery, the download and +the use of FCC’s National Broadband Map +[(NBM)](https://broadbandmap.fcc.gov/home) data. + +## Installation + +You can install the development version of cori.data.fcc from +[GitHub](https://github.com/) with: + +``` r +# install.packages("devtools") +devtools::install_github("ruralinnovation/cori.data.fcc") +``` + +## Example + +This is a basic example which shows some basic workflow: + +``` r +library(cori.data.fcc) + +release <- get_nbm_release() # get the available releases +release +#> filing_type_id filing_type filing_subtype +#> 1 100006 Biannual December 31, 2022 +#> 2 100000 Biannual June 30, 2022 +#> 3 100011 Biannual December 31, 2023 +#> 4 100007 Biannual June 30, 2023 +#> process_uuid enable_bfm_link +#> 1 bbfba324-616d-4247-ab49-933fdd97ff12 TRUE +#> 2 7b81911a-c0cb-4be6-8e6c-63a32e8bf917 TRUE +#> 3 22fad384-b07c-4037-ae8c-58c9f6bbf2c4 TRUE +#> 4 09b52db9-5dab-4414-baa9-3834034be045 TRUE +#> enable_challenge_download +#> 1 TRUE +#> 2 TRUE +#> 3 TRUE +#> 4 TRUE +``` + +You can also inspect what is available: + +``` r +nbm <- get_nbm_available() # get what data is available +# if we are intrested in "Fixed Broadband" / "Nationwide" / released "June 30, 2023" +nbm_filter <- nbm[which(nbm$release == "June 30, 2023" & + nbm$data_type == "Fixed Broadband" & + nbm$data_category == "Nationwide"), ] +rownames(nbm_filter) <- NULL + + +# or +nbm_dplyr_filter <- nbm |> dplyr::filter(release == "June 30, 2023" & + data_type == "Fixed Broadband" & + data_category == "Nationwide") +all.equal(nbm_filter, nbm_dplyr_filter) +#> [1] TRUE +head(nbm_filter) +#> id release data_type technology_code state_fips provider_id +#> 1 628517 June 30, 2023 Fixed Broadband 0 01 +#> 2 628518 June 30, 2023 Fixed Broadband 0 04 +#> 3 628519 June 30, 2023 Fixed Broadband 0 06 +#> 4 628520 June 30, 2023 Fixed Broadband 0 12 +#> 5 628521 June 30, 2023 Fixed Broadband 0 17 +#> 6 628522 June 30, 2023 Fixed Broadband 0 18 +#> file_name file_type data_category +#> 1 bdc_01_Other_fixed_broadband_J23_01jul2024 csv Nationwide +#> 2 bdc_04_Other_fixed_broadband_J23_01jul2024 csv Nationwide +#> 3 bdc_06_Other_fixed_broadband_J23_01jul2024 csv Nationwide +#> 4 bdc_12_Other_fixed_broadband_J23_01jul2024 csv Nationwide +#> 5 bdc_17_Other_fixed_broadband_J23_01jul2024 csv Nationwide +#> 6 bdc_18_Other_fixed_broadband_J23_01jul2024 csv Nationwide +``` + +The package also provide the list of Provider ID and FRN + +``` r +str(fcc_provider) +#> 'data.frame': 4456 obs. of 5 variables: +#> $ provider_name : chr "@Link Services, LLC" "1 Point Communications" "101Netlink" "123.Net, Inc" ... +#> $ affiliation : chr "AtLink Services, LLC" "1 Point Communications" "101Netlink" "123.Net, Inc." ... +#> $ operation_type: chr "Non-ILEC" "Non-ILEC" "Non-ILEC" "Non-ILEC" ... +#> $ frn : chr "0016085920" "0021352968" "0018247254" "0008590846" ... +#> $ provider_id : num 290004 270002 190002 460000 490000 ... +``` + +## Inspiration + +This package was imspired by diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..04c5585 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +comment: false + +coverage: + status: + project: + default: + target: auto + threshold: 1% + informational: true + patch: + default: + target: auto + threshold: 1% + informational: true diff --git a/tests/testthat/test-check_frn.R b/tests/testthat/test-check_frn.R index 4e934a5..8f02d20 100644 --- a/tests/testthat/test-check_frn.R +++ b/tests/testthat/test-check_frn.R @@ -1,18 +1,18 @@ # test if check_frn return a row when called on one frn test_that("check_frn return one row", { - expect_equal(nrow(check_frn(8181448)), 1) + expect_equal(nrow(check_frn(8181448)), 1L) }) # test if check frn retirhn multiple rows # when called with more than one frn number test_that("check_frn return two rows with c()", { - expect_equal(nrow(check_frn(c(8590846, 0021352968))), 2) + expect_equal(nrow(check_frn(c(8590846, 0021352968))), 2L) }) # test if it works with an object test_that("check_frn return two row with object", { frn_test <- c(8590846, 0021352968) - expect_equal(nrow(check_frn(frn_test)), 2) + expect_equal(nrow(check_frn(frn_test)), 2L) }) \ No newline at end of file