# First, make sure your personal PVS API key is saved as character string in the pvs.key variable:
pvs.key <- "yourkey"
# get a data frame of candidates according to all state/officeType/electionYear combinations
candidates <- Candidates.getByOfficeTypeState(stateId=list("NJ","NY"),
officeTypeId=list("C","L"), electionYear=list(2012,2008), all=TRUE)
candidates
# get a data frame of candidates according to the exact state/officeType/electionYear combinations
# (i.e., "NY"/6/2012, "NJ"/7/2008)
candidates <- Candidates.getByOfficeTypeState(stateId=list("NJ","NY"),
officeTypeId=list("C","L"), electionYear=list(2012,2008), all=TRUE)
candidates
Run the code above in your browser using DataLab