/
research_briefings_lists.R
92 lines (70 loc) · 2.21 KB
/
research_briefings_lists.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#' Lists of research briefing topics, subtopics and types.
#'
#' Returns lists of research briefing topics, subtopics and types.
#' These functions do not accept any arguments.
#'
#' @rdname research_briefings_lists
#' @return A list with the different research topics/subtopics/types available.
#' @export
#' @seealso [research_briefings()]
#'
#' @section Member details functions:
#' \describe{
#' \item{research_topics_list}{A list with the different research
#' topics available}
#' \item{research_subtopics_list}{A list of Parliamentary Research
#' Briefings topics}
#' \item{research_types_list}{A list of types of Parliamentary
#' Research Briefings}
#' }
#' @examples
#' \dontrun{
#' research_topics_list <- research_topics_list()
#'
#' research_subtopics_list <- research_subtopics_list()
#'
#' research_types_list <- research_types_list()
#' }
#'
research_topics_list <- function() {
x <- jsonlite::fromJSON(paste0(url_util, "researchbriefingtopics.json?"),
flatten = TRUE
)
research_topics_list <- as.list(x$result$items$prefLabel._value)
research_topics_list
}
#' @rdname research_briefings_lists
#' @export
hansard_research_topics_list <- research_topics_list
#' @rdname research_briefings_lists
#' @export
research_subtopics_list <- function() {
x <- jsonlite::fromJSON(paste0(url_util, "researchbriefingtopics.json?"),
flatten = TRUE
)
research_topics_list <- as.list(x$result$items$prefLabel._value)
research_subtopics_list <- list()
for (i in research_topics_list) {
i <- utils::URLencode(i)
g <- jsonlite::fromJSON(paste0(
url_util, "researchbriefingsubtopics/",
i, ".json?"
), flatten = TRUE)
i <- utils::URLdecode(i)
research_subtopics_list[[i]] <- g$result$items$prefLabel._value
}
research_subtopics_list
}
#' @rdname research_briefings_lists
#' @export
hansard_research_subtopics_list <- research_subtopics_list
#' @rdname research_briefings_lists
#' @export
research_types_list <- function() {
x <- jsonlite::fromJSON(paste0(url_util, "researchbriefingtypes.json?"))
research_types_list <- as.list(x$result$items$prefLabel$`_value`)
research_types_list
}
#' @rdname research_briefings_lists
#' @export
hansard_research_types_list <- research_types_list