Comments (2)
@lepromatous It is in fact the Non-standard evaluation that makes it difficult to put this function within another function. Providing an example is much appreciated. One solution to the problem here is to force quotation of the input, and then take advantage of quasiquotation using !!
. Tidy evaluation, as it's called, is still difficult for me to explain well. If you're interested in learning more Read This
### SOME DATA
data<-data.frame(Address = c("4643 Lindell Blvd", "3545 Lafayette Ave"), City = c("St. Louis", "St. Louis"), State = c("MO", "MO"), ZIP.Code = c(63108, 63104) )
#### BEGIN FUNCTION
geocodeme<-function(data, StateSub, Street.col, City.col, State.col, Zip.col){
#### state subset
sub<-subset(data, toupper(data[,rlang::quo_name(rlang::enquo(State.col))])%in%toupper(StateSub))
require("censusxy") || install.packages("censusxy")
library(censusxy)
##### GEOCODE
Street.col <- rlang::quo_name(rlang::enquo(Street.col))
City.col <- rlang::quo_name(rlang::enquo(City.col))
State.col <- rlang::quo_name(rlang::enquo(State.col))
Zip.col <- rlang::quo_name(rlang::enquo(Zip.col))
results <- cxy_geocode(sub, address = !!Street.col, city = !!City.col, state = !!State.col, zip= !!Zip.col, style="full", output="sf")
require("tigris") || install.packages("tigris")
library(tigris)
require("sf") || install.packages("sf")
library(sf)
### pull state
shp<-block_groups(toupper(StateSub), class="sf")
#### set projection
results <- sf::st_transform(results, "+proj=longlat +datum=WGS84")
shp <- sf::st_transform(shp, "+proj=longlat +datum=WGS84")
require("spatialEco") || install.packages("spatialEco")
library(spatialEco)
out<-point.in.poly(results, shp)
rm(shp)
rm(results)
return(out)
}
#### END FUNCTION
### run function
blah<-geocodeme(data, StateSub="MO", Street.col=Address, City.col=City, State.col=State, Zip.col=ZIP.Code)
from censusxy.
Thanks @lepromatous! @bransonf - lets talk about this today.
from censusxy.
Related Issues (20)
- Travis CI needs migration
- Malformed Response Data HOT 4
- General feedback
- Integrate Github Actions HOT 2
- Non-ASCII characters lead to NA geocoding records HOT 3
- tie HOT 7
- GitHub Actions HOT 2
- cxy_geocode function no longer returning county names when output field specified as "full" HOT 4
- Issue with address batch n > 3 HOT 6
- CRAN issue HOT 4
- vignette typo
- code coverage not working HOT 1
- Update Docs/News with Parallel Support HOT 1
- Inconsistent geocoding (singe vs batch) HOT 1
- Cannot Get Sample to Run HOT 5
- Track + cache progress HOT 3
- cxy_geocode arguments returning "object ___ not found" for existing objects HOT 4
- Parallel processing fails on macOS HOT 7
- `_pkgdown.yml` issue
- Missing Pieces Warning HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from censusxy.