dataBuilder: dataBuilder function

Description Usage Arguments Value Examples

View source: R/dataBuilder.R

Description

This function builds the data frame from the webpage or listURLextractor/rowURLextractor objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
dataBuilder(
  x,
  bylevel = NULL,
  ttime = FALSE,
  typedata = "slow",
  dnames = FALSE,
  tabextract = NULL,
  savetodir = "",
  messages = TRUE
)

Arguments

x

link/list/data frame with links.

bylevel

define data subsets for an output (i.e. single-member districts); if bylevel=NULL the whole data set is returned.

ttime

checks if extracted data covers reported turnout over election day (TRUE) or not (FALSE).

typedata

"slow" if the data is extracted from "rezultaty vyborov" link (slow approach); "fast" if the data is extracted from "svodnya tablitsa" (pivot table) (fast approach).

dnames

assign original labels to column names(TRUE).

tabextract

select the table number to extract in order to override the table selection algorithm.

savetodir

save html data files to specified directory, i.e. "C:/Documents".

messages

display progress messages (TRUE).

Value

The list containing the following parameters:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(CECscraper)

#Example 1
murl<-"http://notelections.online/region/izbirkom?action=show&vrn=27720002327736&region=77&prver=0&pronetvd=null"
uiks <- listURLextractor(
            rowURLextractor(
               listURLextractor(
                   listURLextractor(murl))[1:5,], 'sayt izbiratel`noy komissii sub`yekta'))

uiks_turnout<-rowURLextractor(uiks, "Dannyye ob otkrytii pomeshcheniy dlya golosovaniya")
uiks_voting<-rowURLextractor(uiks, "Rezul`taty vyborov|vyborov po odnomandatnomu \\(mnogomandatnomu\\) okrugu")

uiks_turnout_data<-dataBuilder(uiks_turnout, bylevel="level1", ttime=TRUE)
uiks_voting_data<-dataBuilder(uiks_voting, bylevel="level1", ttime=FALSE)
uiks_merged<-dataMerger(list(uiks_voting_data,uiks_turnout_data), byrow=FALSE)

#Example 2
# library(dplyr)
# murl="http://notelections.online/region/izbirkom?action=show&global=1&vrn=100100084849062&region=0&prver=0&pronetvd=null"
#fast_downloadT<-rowURLextractor(murl, "Predvaritel`nyye svedeniya ob uchastii izbirateley")%>%
#                 listURLextractor()%>%listURLextractor()%>%sample_n(100, replace = FALSE)%>%
#                 rowURLextractor("sayt izbiratel`noy komissii sub`yekta Rossiyskoy Federatsii")%>%
#                 dataBuilder(typedata="fast", bylevel="level2", ttime=TRUE)%>%dataMerger()

kkalininMI/CECscraper documentation built on Oct. 28, 2020, 1:47 a.m.