Skip to content

Commit

Permalink
fixed an error in get_session_cases
Browse files Browse the repository at this point in the history
  • Loading branch information
martigso committed Mar 8, 2024
1 parent a9854b4 commit 6c83311
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Expand Up @@ -15,6 +15,6 @@ Imports: rvest, httr2, parallel, stringr
Suggests: imager, rmarkdown, knitr, pscl
License: GPL (>= 3)
VignetteBuilder: knitr
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
LazyData: true
25 changes: 22 additions & 3 deletions R/get_session_cases.R
Expand Up @@ -142,7 +142,7 @@ get_session_cases <- function(sessionid = NA, good_manners = 0, cores = 1){
names(tmp2$topics) <- tmp2$root$id

# Case proposer
tmp2$proposers <- mclapply((tmp |> html_elements("saker_oversikt > saker_liste > sak > forslagstiller_liste")), function(x){
tmp2$proposers <- lapply((tmp |> html_elements("saker_oversikt > saker_liste > sak > forslagstiller_liste")), function(x){

if(identical(x |> html_elements("representant > id") |> html_text(), character()) == TRUE){
data.frame(rep_id = NA,
Expand All @@ -155,13 +155,32 @@ get_session_cases <- function(sessionid = NA, good_manners = 0, cores = 1){
if(identical((x |> html_elements("representant > fylke > id") |> html_text()), character())) {
county_id = NA
} else {
county_id <- x |> html_elements("representant > fylke > id") |> html_text()
county_id <- x |> html_elements("representant > fylke")

county_id <- lapply(county_id, function(y) {

tmp_county_id <- y |> html_elements("id") |> html_text()

tmp_county_id <- ifelse(identical(character(), tmp_county_id), NA, tmp_county_id)

}) |> unlist()

}

if(identical(x |> html_elements("representant > parti > id") |> html_text(), character())) {
party_id <- NA
} else {
party_id <- x |> html_elements("representant > parti > id") |> html_text()

party_id <- x |> html_elements("representant > parti")

party_id <- lapply(party_id, function(y) {

tmp_party_id <- y |> html_elements("id") |> html_text()

tmp_party_id <- ifelse(identical(character(), tmp_party_id), NA, tmp_party_id)

}) |> unlist()

}

data.frame(rep_id = x |> html_elements("representant > id") |> html_text(),
Expand Down

0 comments on commit 6c83311

Please sign in to comment.