R/pdemethods.r

Defines functions summary.dspl print.dspl

Documented in print.dspl print.dspl summary.dspl summary.dspl

#' @export
#' @rdname dspl-methods
print.dspl <- function(x, path=NULL, replace=FALSE, quiet=FALSE, ...) {
################################################################################
# Printing method
################################################################################  
  if (!is.null(path)) {
  # If output is defined
    
    # Does the file already exists?
    test <- file.exists(path)
    
    # In the case of existance and not replace defined
    if (!replace & test) {
      stop('File ',path,' already exists. Replacement must be explicit.')
    }
    
    # In the case of existance and replace defined
    else if (replace & test) {
      file.remove(path)
      warning('File ', path, ' will be replaced.')
    }
    
    con <- file(description=path, open="w", encoding="UTF-8")
    cat(x$dspl, file=con)
    close.connection(con)
    
    if (!quiet) message("XML successfully stored at\n", normalizePath(path))
  } 
  else {
    cat(x$dspl, ...)
  }
}

#' @export
#' @rdname dspl-methods
summary.dspl <- function(object, ...) {
  ################################################################################
  # Summary method
  ################################################################################  
  cat('Attributes\n')
  print(attributes(object))
  cat('Dataset contents\n')
  object[c('dimtabs', 'slices', 'concepts',
            'dimensions','statistics')]
}
gvegayon/googlePublicData documentation built on June 11, 2021, 11:44 a.m.