get_auselection: Retrieve a .csv dataset from the australian_elections GitHub...

Description Usage Arguments Details Value Examples

View source: R/get_auselection.R

Description

get_auselection() downloads a requested non-filtered or filtered Australian elections dataset given a set of associated arguments.

Usage

1
get_auselection(dsr, opr = "", year = 0)

Arguments

dsr

A character string used to request an Australian elections dataset. See Request Codes below.

opr

A character string used to pass a relational operator (==, =>, =<, <, >, or !=) to the function. Also takes a character string 'range' to download a range of years given as a vector by year. Default of this parameter is set to be an empty string, which also acts as the equivalent (==) operator.

year

A numeric value used to request a specific election year. If there is no election for a given year, returns an empty dataframe. Default value is set to 0, which returns all election years.

Details

Request Codes

An incorrect request (an argument not associated with a dataset, non-character string argument, non-relational operator, or non-numeric election year) will stop function processes and return an error message.

Value

A console printout of arguments used with the function, the requested complete dataset using dsr assigned to a user variable, or the requested dataset dsr for a given election year or years with year and opr to a user assigned variable.

Examples

 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
# Show request codes used for arguments in function.
get_auselection("codes")

# Show in which years an election was held
get_auselection("years")

## Not run: 
# Request the complete Voting Data with IDs dataset.
# Prints a tibble to the console.
with_ids_df <- get_auselection("voting_data_with_ids")

# Preview observations for the dataset.
# Prints a vector to the console.
head(with_ids_df)

# Request only values for the 1975 election from the Voting Data with IDs dataset.
with_ids_1975_df <- get_auselection("voting_data_with_ids", year = 1975)

# Preview observations for the dataset.
head(with_ids_1975_df)

# Request values for the elections within and after 1925.
with_ids_1925up_df <- get_auselection("voting_data_with_ids", opr = ">=", year = 1925)

# Preview observation for the dataset.
head(with_ids_1925up_df)

# Request values for elections from 1925 to 1975.
with_ids_25to75_df <- get_auselection("voting_data_with_ids", opr = "range", year = c(1925, 1975))

# Preview observations for the dataset.
head(with_ids_25to75_df)

## End(Not run)

RohanAlexander/AustralianElections documentation built on Dec. 18, 2021, 10:59 a.m.