24
24
# ' \item topics - text patterns. This filter is a character vector with text patterns of
25
25
# ' topics in order points. Note that the order points are written like
26
26
# ' 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.
29
29
# ' \item content - text patterns. This filter is a character vector with text patterns
30
30
# ' in statements. Note that strings with statements are sentences, so remember about case
31
31
# ' inflection of nouns and adjectives and use stems of words as patterns.
52
52
# ' @param windows information of used operation system; default: .Platform$OS.type == 'windows'
53
53
# ' @param terms_of_office range of terms of office's numbers that will be taken to filter data
54
54
# ' 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)
55
57
# ' @param deputies full names of deputies that will be taken to filter data from database;
56
58
# ' default: character(0)
57
59
# ' @param dates period of time that will be taken to filter data from database;
68
70
# ' \dontrun{
69
71
# ' filtered_statements <- get_filtered_statements()
70
72
# ' dim(filtered_statements)
71
- # ' # [1] 234483 6
73
+ # ' # [1] 2568 6
72
74
# ' names(filtered_statements)
73
75
# ' [1] 'id_statement' 'nr_term_of_office' 'surname_name' 'date_statement'
74
76
# ' [5] 'titles_order_points' 'statement'
75
77
# ' object.size(filtered_statements)
76
- # ' # 148694336 bytes}
78
+ # ' # 6488552 bytes}
77
79
# '
78
80
# ' @note
79
81
# ' 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
109
111
length_topics <- length(topics )
110
112
length_content <- length(content )
111
113
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 ,
113
115
length_topics > = 0 , length_content > = 0 )
114
116
115
117
# connecting to database with dplyr to get statements
@@ -136,11 +138,9 @@ get_filtered_statements <- function(dbname = "sejmrp", user = "reader", password
136
138
statements <- tbl(database_diet , sql(" SELECT * FROM statements" ))
137
139
138
140
# 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 ) {
142
142
statements <- filter(statements , between(nr_term_of_office , terms_of_office [1 ], terms_of_office [2 ]))
143
- }
143
+ }
144
144
145
145
# deputies filter
146
146
if (length_deputies > 0 ) {
@@ -165,7 +165,7 @@ get_filtered_statements <- function(dbname = "sejmrp", user = "reader", password
165
165
statements <- filter(statements , titles_order_points %SIMILAR TO % topics )
166
166
}
167
167
168
- # topics filter
168
+ # content filter
169
169
if (length_content > 0 ) {
170
170
# changing polish characters for any character
171
171
content <- stri_replace_all_regex(content , " [^a-zA-Z %]" , " _" )
@@ -193,4 +193,4 @@ get_filtered_statements <- function(dbname = "sejmrp", user = "reader", password
193
193
suppressWarnings(dbDisconnect(database_diet $ con ))
194
194
return (invisible (statements ))
195
195
196
- }
196
+ }
0 commit comments