File: SDMXServiceProviders-methods.R

package info (click to toggle)
r-cran-rsdmx 1%3A0.6-5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,024 kB
  • sloc: sh: 14; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,331 bytes parent folder | download
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
35
36
37
#' @name SDMXServiceProviders
#' @rdname SDMXServiceProviders
#' @aliases SDMXServiceProviders,SDMXServiceProviders-method
#' 
#' @usage
#'SDMXServiceProviders(providers)
#'
#' @param providers an object of class "list" (of \link{SDMXServiceProvider}) 
#'        configured by default and/or at runtime in \pkg{rsdmx}
#' @return an object of class "SDMXServiceProviders"
#' 
#' @export
#'
SDMXServiceProviders <- function(providers) {
  new("SDMXServiceProviders", providers = providers);
}

#'@export
as.data.frame.SDMXServiceProviders <- function(x, ...){
  out <- as.data.frame(do.call("rbind",
           lapply(slot(x, "providers"),
                  function(provider){
                    
                    builder <- slot(provider, "builder")
                    
                    c(slot(provider,"agencyId"), slot(provider, "name"),
                      slot(provider, "scale"), slot(provider, "country"),
                      class(builder), slot(builder, "compliant"))
                  })),
            stringsAsFactors = FALSE)
  colnames(out) <- c("agencyId", "name", "scale", "country",
                     "builder", "compliant")
  return(encodeSDMXOutput(out))
}

setAs("SDMXGenericData", "data.frame",
      function(from) {as.data.frame.SDMXServiceProviders(from)})