Skip to content

Commit c406e53

Browse files
committed
aktualizacja Tomka
1 parent 712cb32 commit c406e53

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

sejmRP/R/get_filtered_statements.R

+11-11
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#' \item topics - text patterns. This filter is a character vector with text patterns of
2525
#' topics in order points. Note that the order points are written like
2626
#' sentences, so remember about case inflection of nouns and adjectives and use stems of
27-
#' words as patterns. For example if you want to find order points about education (in Polish:
28-
#' szkolnictwo) try 'szkolnictw'. It is possible to choose more than one pattern.
27+
#' words as patterns. For example if you want to find order points about education
28+
#' (in Polish: szkolnictwo) try 'szkolnictw'. It is possible to choose more than one pattern.
2929
#' \item content - text patterns. This filter is a character vector with text patterns
3030
#' in statements. Note that strings with statements are sentences, so remember about case
3131
#' inflection of nouns and adjectives and use stems of words as patterns.
@@ -52,6 +52,8 @@
5252
#' @param windows information of used operation system; default: .Platform$OS.type == 'windows'
5353
#' @param terms_of_office range of terms of office's numbers that will be taken to filter data
5454
#' from database; default: integer(0)
55+
#' @param terms_of_office range of terms of office's numbers that will be taken to filter data
56+
#' from database; default: integer(0)
5557
#' @param deputies full names of deputies that will be taken to filter data from database;
5658
#' default: character(0)
5759
#' @param dates period of time that will be taken to filter data from database;
@@ -68,12 +70,12 @@
6870
#' \dontrun{
6971
#' filtered_statements <- get_filtered_statements()
7072
#' dim(filtered_statements)
71-
#' # [1] 234483 6
73+
#' # [1] 2568 6
7274
#' names(filtered_statements)
7375
#' [1] 'id_statement' 'nr_term_of_office' 'surname_name' 'date_statement'
7476
#' [5] 'titles_order_points' 'statement'
7577
#' object.size(filtered_statements)
76-
#' # 148694336 bytes}
78+
#' # 6488552 bytes}
7779
#'
7880
#' @note
7981
#' Default parameters use privilages of 'reader'. It can only SELECT data from database.
@@ -109,7 +111,7 @@ get_filtered_statements <- function(dbname = "sejmrp", user = "reader", password
109111
length_topics <- length(topics)
110112
length_content <- length(content)
111113

112-
stopifnot(length_terms_of_office >= 0, length_deputies >= 0, length_dates == 0 | length_dates == 2,
114+
stopifnot(length_terms_of_office == 0 | length_terms_of_office == 2, length_deputies >= 0, length_dates == 0 | length_dates == 2,
113115
length_topics >= 0, length_content >= 0)
114116

115117
# connecting to database with dplyr to get statements
@@ -136,11 +138,9 @@ get_filtered_statements <- function(dbname = "sejmrp", user = "reader", password
136138
statements <- tbl(database_diet, sql("SELECT * FROM statements"))
137139

138140
# terms_of_office filter
139-
if (length_terms_of_office == 1) {
140-
statements <- filter(statements, between(nr_term_of_office, terms_of_office[1]))
141-
} else if (length_terms_of_office == 2) {
141+
if (length_terms_of_office == 2) {
142142
statements <- filter(statements, between(nr_term_of_office, terms_of_office[1], terms_of_office[2]))
143-
}
143+
}
144144

145145
# deputies filter
146146
if (length_deputies > 0) {
@@ -165,7 +165,7 @@ get_filtered_statements <- function(dbname = "sejmrp", user = "reader", password
165165
statements <- filter(statements, titles_order_points %SIMILAR TO% topics)
166166
}
167167

168-
# topics filter
168+
# content filter
169169
if (length_content > 0) {
170170
# changing polish characters for any character
171171
content <- stri_replace_all_regex(content, "[^a-zA-Z %]", "_")
@@ -193,4 +193,4 @@ get_filtered_statements <- function(dbname = "sejmrp", user = "reader", password
193193
suppressWarnings(dbDisconnect(database_diet$con))
194194
return(invisible(statements))
195195

196-
}
196+
}

sejmRP/man/get_filtered_statements.Rd

+7-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)