Skip to content

Commit

Permalink
finishing cran checks
Browse files Browse the repository at this point in the history
  • Loading branch information
martigso committed Jan 18, 2024
1 parent 9540770 commit 0e893a9
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 73 deletions.
40 changes: 15 additions & 25 deletions R/get_session_decisions.R
Expand Up @@ -80,20 +80,21 @@ get_session_decisions <- function(sessionid = NA, good_manners = 0){
tmp <- resp |>
resp_body_html(check_type = FALSE, encoding = "utf-8")

tmp2 <- data.frame(response_date = tmp |> html_elements("stortingsvedtak_oversikt > respons_dato_tid") |> html_text(),
version = tmp |> html_elements("stortingsvedtak_oversikt > versjon") |> html_text(),
session_id = tmp |> html_elements("stortingsvedtak_oversikt > sesjon_id") |> html_text(),
decision_id = tmp |> html_elements("stortingsvedtak > id") |> html_text(),
case_id = tmp |> html_elements("stortingsvedtak > sak_id") |> html_text(),
case_link_url = tmp |> html_elements("stortingsvedtak > sak_lenke_url") |> html_text(),
decision_date = tmp |> html_elements("stortingsvedtak > stortingsvedtak_dato_tid") |> html_text(),
decision_link_url = tmp |> html_elements("stortingsvedtak > stortingsvedtak_lenke_url") |> html_text(),
decision_number = tmp |> html_elements("stortingsvedtak > stortingsvedtak_nummer") |> html_text(),
decision_title = tmp |> html_elements("stortingsvedtak > stortingsvedtak_tittel") |> html_text())
tmp2 <- data.frame(response_date = tmp %>% html_elements("stortingsvedtak_oversikt > respons_dato_tid") %>% html_text(),
version = tmp %>% html_elements("stortingsvedtak_oversikt > versjon") %>% html_text(),
session_id = tmp %>% html_elements("stortingsvedtak_oversikt > sesjon_id") %>% html_text(),
decision_id = tmp %>% html_elements("stortingsvedtak > id") %>% html_text(),
case_id = tmp %>% html_elements("stortingsvedtak > sak_id") %>% html_text(),
case_link_url = tmp %>% html_elements("stortingsvedtak > sak_lenke_url") %>% html_text(),
decision_date = tmp %>% html_elements("stortingsvedtak > stortingsvedtak_dato_tid") %>% html_text(),
decision_link_url = tmp %>% html_elements("stortingsvedtak > stortingsvedtak_lenke_url") %>% html_text(),
decision_number = tmp %>% html_elements("stortingsvedtak > stortingsvedtak_nummer") %>% html_text(),
decision_text = tmp %>% html_elements("stortingsvedtak > stortingsvedtak_tekst") %>% html_text(),
decision_title = tmp %>% html_elements("stortingsvedtak > stortingsvedtak_tittel") %>% html_text())

decision_type_id <- lapply(tmp |> html_elements("stortingsvedtak > stortingsvedtak_type"), function(x){
decision_type_id <- lapply(tmp %>% html_elements("stortingsvedtak > stortingsvedtak_type"), function(x){

tmp_id <- x |> html_elements("id") |> html_text()
tmp_id <- x %>% html_elements("id") %>% html_text()

if(identical(tmp_id, character())){
tmp_id <- NA
Expand All @@ -103,9 +104,9 @@ get_session_decisions <- function(sessionid = NA, good_manners = 0){

})

decision_type_name <- lapply(tmp |> html_elements("stortingsvedtak > stortingsvedtak_type"), function(x){
decision_type_name <- lapply(tmp %>% html_elements("stortingsvedtak > stortingsvedtak_type"), function(x){

tmp_id <- x |> html_elements("navn") |> html_text()
tmp_id <- x %>% html_elements("navn") %>% html_text()

if(identical(tmp_id, character())){
tmp_id <- NA
Expand All @@ -115,17 +116,6 @@ get_session_decisions <- function(sessionid = NA, good_manners = 0){

})

decision_text <- lapply(tmp |> html_elements("stortingsvedtak > stortingsvedtak_tekst"), function(x){

if(x |> html_text() == "") {
return("")
}

x |> html_text() |> read_html() |> html_text() |> trimws()

}) |> unlist()

tmp2$decision_text <- decision_text
tmp2$decision_type_id <- do.call(c, decision_type_id)
tmp2$decision_type_name <- do.call(c, decision_type_name)

Expand Down
3 changes: 2 additions & 1 deletion revdep/.gitignore
Expand Up @@ -4,4 +4,5 @@ checks.noindex
library.noindex
data.sqlite
*.html
**/
**/
cloud.noindex
89 changes: 45 additions & 44 deletions revdep/README.md
@@ -1,52 +1,53 @@
# Platform

|field |value |
|:--------|:-------------------------------------------|
|version |R version 4.2.2 Patched (2022-11-10 r83330) |
|os |Ubuntu 22.04.2 LTS |
|system |x86_64, linux-gnu |
|ui |RStudio |
|language |(EN) |
|collate |en_US.UTF-8 |
|ctype |en_US.UTF-8 |
|tz |Europe/Oslo |
|date |2023-03-10 |
|rstudio |2022.12.0+353 Elsbeth Geranium (desktop) |
|pandoc |2.9.2.1 @ /usr/bin/pandoc |
|field |value |
|:--------|:-----------------------------------|
|version |R version 4.3.2 (2023-10-31) |
|os |Manjaro Linux |
|system |x86_64, linux-gnu |
|ui |RStudio |
|language |(EN) |
|collate |en_US.UTF-8 |
|ctype |en_US.UTF-8 |
|tz |Europe/Oslo |
|date |2024-01-18 |
|rstudio |2023.12.0+369 Ocean Storm (desktop) |
|pandoc |3.1.6 @ /usr/bin/ (via rmarkdown) |

# Dependencies

|package |old |new |Δ |
|:--------------|:------|:------|:--|
|stortingscrape |0.1.2 |0.1.3 |* |
|askpass |1.1 |1.1 | |
|cli |3.6.0 |3.6.0 | |
|curl |5.0.0 |5.0.0 | |
|dplyr |1.1.0 |1.1.0 | |
|fansi |1.0.4 |1.0.4 | |
|generics |0.1.3 |0.1.3 | |
|glue |1.6.2 |1.6.2 | |
|httr |1.4.5 |1.4.5 | |
|jsonlite |1.8.4 |1.8.4 | |
|lifecycle |1.0.3 |1.0.3 | |
|magrittr |2.0.3 |2.0.3 | |
|mime |0.12 |0.12 | |
|openssl |2.0.6 |2.0.6 | |
|pillar |1.8.1 |1.8.1 | |
|pkgconfig |2.0.3 |2.0.3 | |
|R6 |2.5.1 |2.5.1 | |
|rlang |1.0.6 |1.0.6 | |
|rvest |1.0.3 |1.0.3 | |
|selectr |0.4-2 |0.4-2 | |
|stringi |1.7.12 |1.7.12 | |
|stringr |1.5.0 |1.5.0 | |
|sys |3.4.1 |3.4.1 | |
|tibble |3.2.0 |3.2.0 | |
|tidyselect |1.2.0 |1.2.0 | |
|utf8 |1.2.3 |1.2.3 | |
|vctrs |0.5.2 |0.5.2 | |
|withr |2.5.0 |2.5.0 | |
|xml2 |1.3.3 |1.3.3 | |
|package |old |new |Δ |
|:--------------|:-----|:-----|:--|
|stortingscrape |0.1.3 |0.2.0 |* |
|askpass |1.2.0 |1.2.0 | |
|cli |3.6.2 |3.6.2 | |
|curl |5.2.0 |5.2.0 | |
|dplyr |1.1.4 |NA |* |
|fansi |1.0.6 |1.0.6 | |
|generics |0.1.3 |NA |* |
|glue |1.7.0 |1.7.0 | |
|httr |1.4.7 |1.4.7 | |
|httr2 |NA |1.0.0 |* |
|jsonlite |NA |1.8.8 |* |
|lifecycle |1.0.4 |1.0.4 | |
|magrittr |2.0.3 |2.0.3 | |
|mime |0.12 |0.12 | |
|openssl |2.1.1 |2.1.1 | |
|pillar |1.9.0 |1.9.0 | |
|pkgconfig |2.0.3 |2.0.3 | |
|R6 |2.5.1 |2.5.1 | |
|rlang |NA |1.1.3 |* |
|rvest |1.0.3 |1.0.3 | |
|selectr |0.4-2 |0.4-2 | |
|stringi |1.8.3 |1.8.3 | |
|stringr |1.5.1 |1.5.1 | |
|sys |3.4.2 |3.4.2 | |
|tibble |3.2.1 |3.2.1 | |
|tidyselect |1.2.0 |NA |* |
|utf8 |1.2.4 |1.2.4 | |
|vctrs |0.6.5 |0.6.5 | |
|withr |NA |3.0.0 |* |
|xml2 |1.3.6 |1.3.6 | |

# Revdeps

Binary file modified revdep/data.sqlite
Binary file not shown.
8 changes: 7 additions & 1 deletion vignettes/refs.bib
Expand Up @@ -183,4 +183,10 @@ @Article{Turner-Zwinkels2021
keywords = {parliaments, politician level data, population instability, who-is-who, tenure, gender, professionalization, turnover, open-source database},
}

@Comment{jabref-meta: databaseType:bibtex;}
@Manual{wickham2023,
title = {httr2: Perform HTTP Requests and Process the Responses},
author = {Hadley Wickham},
year = {2023},
note = {R package version 1.0.0, https://github.com/r-lib/httr2},
url = {https://httr2.r-lib.org},
}
4 changes: 2 additions & 2 deletions vignettes/stortingscrape.Rmd
Expand Up @@ -137,8 +137,8 @@ are expected to often be ran repeatedly have a `good_manners` argument.
This will make R sleep for the set amount of seconds after calling
the API. It is recommended to set this argument to 2 seconds or higher on multiple
calls to the API. Generally, the package is built by the recommendations given
by the `httr` package [@Wickham2020]^[Especially, see
https://cran.r-project.org/package=httr/vignettes/api-packages.html].
by the `httr2` package [@wickham2023]^[Especially, see
https://httr2.r-lib.org/articles/wrapping-apis.html].

Most of the data from Stortinget's API and frontend web page are interconnected
through ids for the various sources (session id, MP id, case id, question id,
Expand Down

0 comments on commit 0e893a9

Please sign in to comment.