search_cities_in_states: Searches vector for cities (based on whether vector includes...

Description Usage Arguments Details Examples

View source: R/search_cities_in_states.R View source: R/search_cities.R

Description

This function takes a vector input and searches presence of #' any text that appears to be a zipcode by looking for sequences of numbers. Specifically, it first identifies whether any string appears to be a state name or state abbreviation, then determines whether the preceding text appears to be a city in that state.

This function takes a vector input and searches presence of #' any text that appears to be a zipcode by looking for sequences of numbers. Specifically, it first identifies whether any string appears to be a state name or state abbreviation, then determines whether the preceding text appears to be a city in that state.

Usage

1
2
3

Arguments

vec

A vector input whose contents need to be searched for references to city names

output

The desired output of function. Defaults to "vector" where T/F vector result is returned. The argument "dt" will output a table of original vector input, T/F vector result, and the matching substring.

Details

The default output is a TRUE/FALSE vector but the function can also return a dataframe of the original vector input, the TRUE/FALSE result, and the substring that matched the zipcode pattern.

The default output is a TRUE/FALSE vector but the function can also return a dataframe of the original vector input, the TRUE/FALSE result, and the substring that matched the city/state pattern.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
fakeaddresses <- c("820 Nut Swamp Ave.
Toms River, NJ 08753",
                   "982 Clay Street
                   Lenoir, NC 28645",
                   "4 NW. Mayfield Rd.
                   Springfield Gardens, NY 11413",
                   "20 Elmwood Street
                   Raleigh, NC 27603",
                   "196 E. Green Lake Road
                   Birmingham, AL 35209",
                   "73 Beechwood Dr.
                   La Crosse, WI VA DC 54601")

search_cities_in_states(fakeaddresses)


fakeaddresses <- c("820 Nut Swamp Ave.
Toms River, NJ 08753",
                   "982 Clay Street
                   Lenoir, NC 28645",
                   "4 NW. Mayfield Rd.
                   Springfield Gardens, NY 11413",
                   "20 Elmwood Street
                   Raleigh, NC 27603",
                   "196 E. Green Lake Road
                   Birmingham, AL 35209",
                   "73 Beechwood Dr.
                   La Crosse, WI VA DC 54601")

search_cities_in_states(fakeaddresses)

DevikaNair90/prybar documentation built on May 11, 2020, 2:47 a.m.