add_prediction: add a prediciton (to a pollyvote object)

Description Usage Arguments Value Examples

Description

Adds a prediction, so far only implemented for pollyvote objects.

Usage

1
add_prediction(pv, method, 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.