Skip to content

Commit

Permalink
Merge branch 'main' into pkgdown
Browse files Browse the repository at this point in the history
  • Loading branch information
defuneste authored Jul 24, 2024
2 parents 19d61c1 + 6072a57 commit daba2bb
Show file tree
Hide file tree
Showing 10 changed files with 314 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
^_pkgdown\.yml$
^docs$
^pkgdown$
^README\.Rmd$
^codecov\.yml$
^\.github$
52 changes: 52 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -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")'
61 changes: 61 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ Imports:
jsonlite,
utils,
DBI,
duckdb
URL: https://ruralinnovation.github.io/cori.data.fcc/
pkgdown,
duckdb,
stringi
URL: https://ruralinnovation.github.io/cori.data.fcc/
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export(get_nbm_available)
export(get_nbm_release)
import(DBI)
import(duckdb)
importFrom(stringi,stri_pad_left)
4 changes: 3 additions & 1 deletion R/check_frn.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
73 changes: 73 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# cori.data.fcc

<!-- badges: start -->
[![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)
<!-- badges: end -->

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
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# cori.data.fcc

<!-- badges: start -->

[![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)
<!-- badges: end -->

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 <NA>
#> 2 628518 June 30, 2023 Fixed Broadband 0 04 <NA>
#> 3 628519 June 30, 2023 Fixed Broadband 0 06 <NA>
#> 4 628520 June 30, 2023 Fixed Broadband 0 12 <NA>
#> 5 628521 June 30, 2023 Fixed Broadband 0 17 <NA>
#> 6 628522 June 30, 2023 Fixed Broadband 0 18 <NA>
#> 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 <https://github.com/bbcommons/bfm-explorer>
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true
6 changes: 3 additions & 3 deletions tests/testthat/test-check_frn.R
Original file line number Diff line number Diff line change
@@ -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)
})

0 comments on commit daba2bb

Please sign in to comment.