#' Отримайте короткий опис політики
#'
#' @param id Вектор, який містить id депутата (має складатись щонайменше з одного елементу). За замовчуванням має значення '2524', що відповідає першому за алфавітом нардепу - Олександру Абдулліну
#'
#' @param key Ваш персональний ключ API, отриманий на rada4you.org
#'
#' @return Датафрейм, що складається з шести змінних для кожного депутата: id, mp, party, rebellions, attended, possible
#'
#' @export
#'
voting <- function(start_date, end_date, key) {
dates = seq(as.Date(start_date), as.Date(end_date), by = 1)
all_votes <- data.frame()
for(i in as.list(dates)) {
request <- httr::GET(url = "https://rada4you.org/",
path = paste0("/api/v1/divisions.json"),
query = list(key = key, end_date = i, start_date = i, house="rada"))
if(httr::status_code(request) != 200) {
message(paste('Помилка. Код відповіді сервера: '), httr::status_code(request))
} else {
response <- httr::content(request, as = 'text')
json <- jsonlite::fromJSON(response)
print(request)
votes <- data.frame(
id = json$id,
name = json$name,
date = json$date,
time = json$clock_time,
aye_votes = json$aye_votes,
no_votes = json$no_votes,
possible_turnout = json$possible_turnout,
rebellions = json$rebellions,
edited = json$edited,
stringsAsFactors = F)
all_votes <- rbind.data.frame(all_votes, votes)
}
}
return(all_votes)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.