add_prediction.pollyvote: add data to a pollyvote object

Description Usage Arguments Value Examples

Description

Adds data to a pollyvote opbject.

Usage

1
2
3
## S3 method for class 'pollyvote'
add_prediction(pv, method = "no_aggregation",
  fun = function(pv) {     get_data(pv) }, ...)

Arguments

pv

[pollyvote]
the pollyvote object to add the data to.

method

[character(1)]
method of the prediction. This method name will be used to call the prediction in predict.pollyvote.

fun

[function(pv)]

...

additional arguments

Value

The pollyvote object with added prediction

Examples

1
2
3
4
5
6
7
8
pv = create_pollyvote(perm_countries = "D")
pv = add_prediction(pv, "poll", function(pv) {
  pv %>% 
    get_data %>% 
    filter(source_type %in% c("poll")) %>%
    group_by(date, source_type, party) %>% 
    summarize(percent = mean(percent, na.rm = TRUE))
})

pollyvote/pollyvoter documentation built on May 25, 2019, 11:23 a.m.