#' @title hej
#' @description hejsan description
#' @field formula Formula
#' @export electio
#' @export
#'
#path <- "2014_landstingsval_per_kommun.xls"
electio <- setRefClass("electio",
fields = list(path = "character", electio = "data.frame"),
methods = list(
initialize = function(path){
# Library packages for fetching data
library(readxl)
library(httr)
url <- paste("www.val.se/val/val2014/statistik/",path, sep="")
dataaa <- GET(url, write_disk(tdf <- tempfile(fileext = ".xls")))
datafr <- read_excel(tdf, skip = 2)
electio <<- datafr
#print(datafr)
},
get_Mtal= function(){
stopifnot(get_Mtal == datafr$`M tal`)
return(get_Mtal)
},
get_Ctal= function(){
stopifnot(get_Ctal == datafr$`C tal`)
return(get_Ctal)
},
get_FPtal= function(){
stopifnot(get_FPtal == datafr$`FP tal`)
return(get_FPtal)
},
get_KDtal= function(){
stopifnot(get_KDtal == datafr$`KD tal`)
return(get_KDtal)
},
get_Stal = function(){
stopifnot( get_Stal == datafr$`S tal`)
return(get_Stal)
},
get_Vtal= function(){
stopifnot(get_Vtal == datafr$`V tal`)
return(get_Vtal)
},
get_MPtal= function(){
stopifnot(get_MPtal == datafr$`MP tal`)
return(get_MPtal)
},
get_SDtal= function(){
stopifnot(get_SDtal == datafr$`SD tal`)
return(get_SDtal)
},
get_FItal= function(){
stopifnot(get_FItal == datafr$`FI tal`)
return(get_FItal)
}
))
test_exempel <- electio$new("2014_landstingsval_per_kommun.xls")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.