# 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/office/electionYear combinations
candidates <- Candidates.getByOfficeState(stateId=list("NJ","NY"),officeId=list(6,7),
electionYear=list(2012,2008), all=TRUE)
candidates
# get a data frame of candidates according to the exact state/office/electionYear combinations
# (i.e., "NY"/6/2012, "NJ"/7/2008)
candidates <- Candidates.getByOfficeState(stateId=list("NJ","NY"),officeId=list(6,7),
electionYear=list(2012,2008), all=TRUE)
candidates
Run the code above in your browser using DataLab