Skip to content

Commit 4c0e4ca

Browse files
committed
feat: changed function names to prevent any conflicts
1 parent 5e4a123 commit 4c0e4ca

File tree

13 files changed

+96
-96
lines changed

13 files changed

+96
-96
lines changed

NAMESPACE

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
export(abbr)
4-
export(county)
5-
export(geometry)
6-
export(metadata)
7-
export(state)
3+
export(fips_abbr)
4+
export(fips_county)
5+
export(fips_geometry)
6+
export(fips_metadata)
7+
export(fips_state)

NEWS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
* Added a `NEWS.md` file to track changes to the package.
44
* Initial commit to version control with the following functions:
5-
- `abbr()` - Gets state abbreviation.
6-
- `state()` - Gets state name.
7-
- `county()` - Gets county name.
8-
- `geometry()` - Gets geometry.
9-
- `metadata()` - Gets the information above as a `data.frame`.
5+
- `fips_abbr()` - Gets state abbreviation.
6+
- `fips_state()` - Gets state name.
7+
- `fips_county()` - Gets county name.
8+
- `fips_geometry()` - Gets geometry.
9+
- `fips_metadata()` - Gets the information above as a `data.frame`.

R/fipio.R

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,56 @@
22
#' @param fip 2-digit or 5-digit FIPS code
33
#' @return a `character` vector
44
#' @examples
5-
#' fipio::abbr("37")
6-
#' fipio::abbr("06001")
5+
#' fipio::fips_abbr("37")
6+
#' fipio::fips_abbr("06001")
77
#'
88
#' @export
9-
abbr <- function(fip) {
9+
fips_abbr <- function(fip) {
1010
tmp <- unique(fips_[, c(1, 4)])
1111
tmp[[2]][match(substr(fip, 1, 2), tmp[[1]])]
1212
}
1313

1414
#' @title Get the state name for a FIPS code
15-
#' @inheritParams abbr
15+
#' @inheritParams fips_abbr
1616
#' @return a `character` vector
1717
#' @examples
18-
#' fipio::state("37")
19-
#' fipio::state("06001")
18+
#' fipio::fips_state("37")
19+
#' fipio::fips_state("06001")
2020
#'
2121
#' @export
22-
state <- function(fip) {
22+
fips_state <- function(fip) {
2323
tmp <- unique(fips_[, c(1, 5)])
2424
tmp[[2]][match(substr(fip, 1, 2), tmp[[1]])]
2525
}
2626

2727
#' @title Get the county name for a FIPS code
28-
#' @inheritParams abbr
28+
#' @inheritParams fips_abbr
2929
#' @return a `character` vector
3030
#' @examples
31-
#' fipio::county("37129")
32-
#' fipio::county("06001")
31+
#' fipio::fips_county("37129")
32+
#' fipio::fips_county("06001")
3333
#'
3434
#' # 2-digit FIP codes will not work
35-
#' fipio::county("37")
35+
#' fipio::fips_county("37")
3636
#'
3737
#' @export
38-
county <- function(fip) {
38+
fips_county <- function(fip) {
3939
tmp <- fips_[, c(3, 6)]
4040
tmp[[2]][match(fip, tmp[[1]])]
4141
}
4242

4343

4444
#' @title Get the geometry for a FIPS code
45-
#' @inheritParams abbr
45+
#' @inheritParams fips_abbr
4646
#' @return an `sfg`/`sfc` object
4747
#' @examples
4848
#' \dontrun{
49-
#' fipio::geometry("37")
50-
#' fipio::geometry("06001")
49+
#' fipio::fips_geometry("37")
50+
#' fipio::fips_geometry("06001")
5151
#' }
5252
#'
5353
#' @export
54-
geometry <- function(fip) {
54+
fips_geometry <- function(fip) {
5555
if (.has_sfheaders()) {
5656
geo_$geometry[match(fip, geo_$fip_code)]
5757
} else {
@@ -60,15 +60,15 @@ geometry <- function(fip) {
6060
}
6161

6262
#' @title Get the metadata for a FIPS code
63-
#' @inheritParams abbr
63+
#' @inheritParams fips_abbr
6464
#' @param geometry If `TRUE`, returns a geometry column (requires `sfheaders`)
6565
#' @return a `data.frame`
6666
#' @examples
67-
#' fipio::metadata("37")
68-
#' fipio::metadata("06001")
67+
#' fipio::fips_metadata("37")
68+
#' fipio::fips_metadata("06001")
6969
#'
7070
#' @export
71-
metadata <- function(fip, geometry = FALSE) {
71+
fips_metadata <- function(fip, geometry = FALSE) {
7272
df <- do.call(rbind, lapply(
7373
X = fip,
7474
FUN = function(f) {
@@ -89,7 +89,7 @@ metadata <- function(fip, geometry = FALSE) {
8989
}
9090
))
9191

92-
if (geometry) df$geometry <- geometry(df$fip_code)
92+
if (geometry) df$geometry <- fips_geometry(df$fip_code)
9393

9494
rownames(df) <- NULL
9595

README.Rmd

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ Let's answer a few questions that might come up if you have a FIPS code:
5151
fip <- "37129"
5252
5353
# What state is `37129` in?
54-
fipio::state(fip)
54+
fipio::fips_state(fip)
5555
5656
# Alternatively, you can use the state FIPS code by itself
57-
fipio::state("37")
57+
fipio::fips_state("37")
5858
5959
# What about the state abbreviation?
60-
fipio::abbr(fip)
60+
fipio::fips_abbr(fip)
6161
6262
# What county is `37129`?
63-
fipio::county(fip)
63+
fipio::fips_county(fip)
6464
6565
# It'd be nice to have this all in a data.frame...
66-
fipio::metadata(fip)
66+
fipio::fips_metadata(fip)
6767
6868
# And the metadata for the state by itself...
69-
fipio::metadata("37")
69+
fipio::fips_metadata("37")
7070
```
7171

7272
### With `sf`
@@ -79,24 +79,24 @@ library(sf, quietly = TRUE)
7979

8080
```{r}
8181
# I'm doing spatial work, what's the geometry of `37129`?
82-
fipio::geometry(fip)
82+
fipio::fips_geometry(fip)
8383
8484
# What if I need it with my other metadata?
85-
fipio::metadata(fip, geometry = TRUE)
85+
fipio::fips_metadata(fip, geometry = TRUE)
8686
```
8787

8888
### Vectorized
8989
`fipio` functions are inherently vectorized, so you can use them with vectors of FIPS codes easily:
9090
```{r}
9191
fips <- c("37129", "44001", "48115")
9292
93-
fipio::state(fips)
93+
fipio::fips_state(fips)
9494
95-
fipio::abbr(fips)
95+
fipio::fips_abbr(fips)
9696
97-
fipio::county(fips)
97+
fipio::fips_county(fips)
9898
99-
fipio::metadata(fips)
99+
fipio::fips_metadata(fips)
100100
101-
fipio::geometry(fips)
101+
fipio::fips_geometry(fips)
102102
```

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,28 @@ answer a few questions that might come up if you have a FIPS code:
4646
fip <- "37129"
4747

4848
# What state is `37129` in?
49-
fipio::state(fip)
49+
fipio::fips_state(fip)
5050
#> [1] "North Carolina"
5151

5252
# Alternatively, you can use the state FIPS code by itself
53-
fipio::state("37")
53+
fipio::fips_state("37")
5454
#> [1] "North Carolina"
5555

5656
# What about the state abbreviation?
57-
fipio::abbr(fip)
57+
fipio::fips_abbr(fip)
5858
#> [1] "NC"
5959

6060
# What county is `37129`?
61-
fipio::county(fip)
61+
fipio::fips_county(fip)
6262
#> [1] "New Hanover"
6363

6464
# It'd be nice to have this all in a data.frame...
65-
fipio::metadata(fip)
65+
fipio::fips_metadata(fip)
6666
#> state_code county_code fip_code state_abbr state_name county_name
6767
#> 1 37 129 37129 NC North Carolina New Hanover
6868

6969
# And the metadata for the state by itself...
70-
fipio::metadata("37")
70+
fipio::fips_metadata("37")
7171
#> state_code state_abbr state_name fip_code
7272
#> 1 37 NC North Carolina 37
7373
```
@@ -80,7 +80,7 @@ geometry object back.
8080

8181
``` r
8282
# I'm doing spatial work, what's the geometry of `37129`?
83-
fipio::geometry(fip)
83+
fipio::fips_geometry(fip)
8484
#> Geometry set for 1 feature
8585
#> Geometry type: MULTIPOLYGON
8686
#> Dimension: XY
@@ -89,7 +89,7 @@ fipio::geometry(fip)
8989
#> MULTIPOLYGON (((-78.02992 34.33177, -77.82268 3...
9090

9191
# What if I need it with my other metadata?
92-
fipio::metadata(fip, geometry = TRUE)
92+
fipio::fips_metadata(fip, geometry = TRUE)
9393
#> state_code county_code fip_code state_abbr state_name county_name
9494
#> 1 37 129 37129 NC North Carolina New Hanover
9595
#> geometry
@@ -104,22 +104,22 @@ vectors of FIPS codes easily:
104104
``` r
105105
fips <- c("37129", "44001", "48115")
106106

107-
fipio::state(fips)
107+
fipio::fips_state(fips)
108108
#> [1] "North Carolina" "Rhode Island" "Texas"
109109

110-
fipio::abbr(fips)
110+
fipio::fips_abbr(fips)
111111
#> [1] "NC" "RI" "TX"
112112

113-
fipio::county(fips)
113+
fipio::fips_county(fips)
114114
#> [1] "New Hanover" "Bristol" "Dawson"
115115

116-
fipio::metadata(fips)
116+
fipio::fips_metadata(fips)
117117
#> state_code county_code fip_code state_abbr state_name county_name
118118
#> 1 37 129 37129 NC North Carolina New Hanover
119119
#> 2 44 001 44001 RI Rhode Island Bristol
120120
#> 3 48 115 48115 TX Texas Dawson
121121

122-
fipio::geometry(fips)
122+
fipio::fips_geometry(fips)
123123
#> Geometry set for 3 features
124124
#> Geometry type: MULTIPOLYGON
125125
#> Dimension: XY

man/abbr.Rd renamed to man/fips_abbr.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/county.Rd renamed to man/fips_county.Rd

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geometry.Rd renamed to man/fips_geometry.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/metadata.Rd renamed to man/fips_metadata.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/state.Rd renamed to man/fips_state.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)