jblumenau / twfyR

R binding for TheyWorkForYou
7 stars 1 forks source link

getHansard() throws error 'Error in getHansard() : object 'gid' not found' #5

Open nikloynes opened 3 years ago

nikloynes commented 3 years ago

Hi there. love this package, thanks for sharing! I'm trying to iterate through a list of MPs and get their entire contribution history from date t to today.

I have a vector with n person_ids that I want to run a for-loop over, something like this:

for i in 1:length(mps){  
contrib_df <- getHansard(person = mps[i], complete_call = T)  
contrib_df <- contrib_df %>%   
filter(date >= start_date)  
write.csv(contrib_df, paste0(DATA_OUT, 'contrib_', mps[i], '.csv))
}

And even when testing outside of the loop, this function doesn't seem to work, giving me this error: Error in getHansard(person = mps[i], complete_call = T) : object 'gid' not found

I had a look in the code for getHansard(), and as far as I can tell it requires a gid var in it, however this isn't assignable or declared within the code.

Would be sweet if you had an idea on how to fix this?

Best & thanks, Nik

nikloynes commented 3 years ago

a brief fix that I implemented myself -- I commented out line 23 in the code for getHansard(). Not ideal - so won't send a pull req - but works for my application. This is the line in question:
if(sum(!is.na(c(date,search,person, gid))) > 1) stop("You can only supply one of 'date', 'search', 'person', or 'gid' at present. See https://www.theyworkforyou.com/api/docs/getDebates for more information.")