# First, make sure your personal PVS API key is saved as character string in the pvs.key variable:
pvs.key <- "yourkey"
# get districts for certain office and state IDs
districts <- District.getByOfficeState(officeId=list(8,9),stateId=list("NY","NJ"))
district
# get a data frame of districts according to all state/office/districtName combinations
districts <- District.getByOfficeState(officeId=list(8,9),stateId=list("NY","NJ"),
districtName=list(1,2), all=TRUE)
districts
# get a data frame of districts according to the exact state/office/districtName combinations
# (i.e., 8/"NY"/1, 9/"NJ"/2)
districts <- District.getByOfficeState(officeId=list(8,9),stateId=list("NY","NJ"),
districtName=list(1,2), all=FALSE)
districts
Run the code above in your browser using DataLab