DataFormat: Superclass for data format information

Description Usage Format Details Fields Getters/setters Public methods Author(s) References Examples

Description

TODO

Usage

1

Format

1
2
Class 'R6ClassGenerator' <environment: 0x0000000009bde5d0> 
 - attr(*, "name")= chr "DataFormat_generator"

Details

TODO

Fields

format

list Data format information

Getters/setters

Public methods

Author(s)

Janko Thyson janko.thyson@rappster.de

References

http://github.com/rappster/datar

Examples

 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Example formats ----------------------------------------------------------

format_1 <- list(
  function(x, pattern = "\\d{4}-\\d{2}-\\d{2}") {
    tmp <- lapply(x, function(ii) {
      if (any(grepl(pattern, ii))) {
        as.POSIXlt(ii)
      } else {
        ii
      }
    })
    as.data.frame(tmp, stringsAsFactors = FALSE)
  },
  function(x) {
    names(x) <- gsub("\\.", "_", names(x))
    x
  }
)
format_2 <- list(
  function(x, pattern = "\\d{4}-\\d{2}-\\d{2}") {
    tmp <- lapply(x, function(ii) {
      if (any(grepl(pattern, ii))) {
        as.character(ii)
      } else {
        ii
      }
    })
    as.data.frame(tmp, stringsAsFactors = FALSE)
  },
  function(x) {
    names(x) <- gsub("_", ".", names(x))
    x
  }
)

# Instantiate -------------------------------------------------------------

format_1_inst <- DataFormat$new(format = format_1)
format_2_inst <- DataFormat$new(format = format_2)

# Methods -----------------------------------------------------------------

format_1_inst$getFormat()
format_1_inst$setFormat(NULL)
format_1_inst$getFormat()
format_1_inst$setFormat(format_2)
format_1_inst$getFormat()

format_2_inst$getFormat()
format_2_inst$setFormat(NULL)
format_2_inst$getFormat()
format_2_inst$setFormat(format_1)
format_2_inst$getFormat()

rappster/dataconr documentation built on May 26, 2019, 11:14 p.m.