Description Usage Arguments Value Examples
View source: R/errorcalculation.R
Average Error by State This function calculates the average error and checks that the idenifiers match.
1 | average_error(predicted, actual)
|
predicted |
the predictions including the first column with a character vector with idenifiers to check that the rows of predicted and actual match |
actual |
the real result including the first column with a character vector |
This function returns the average error for each state.
1 2 3 4 5 6 | predict1 = data.frame(state = c("TX", "GA", "OR"), dem = c(.45, .49, .63), rep = c(.55, .51, .37))
actual1 = data.frame(state = c("TX", "GA", "OR"), dem = c(.42, .48, .62), rep = c(.58, .52, .38))
average_error(predict1, actual1)
predict2 = data.frame(state = c("OK", "MS", "WY"), dem = c(.42, .44, .3), rep = c(.56, .55, .7), other = c(0.02, 0.01, 0))
actual2 = data.frame(state = c("OK", "MS", "WY"), dem = c(.41, .38, .3), rep = c(.55, .58, .69), other = c(0.04, 0.04, 0.01))
average_error(predict2, actual2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.