pik-piam / magclass

R package | Data Class and Tools for Handling Spatial-Temporal Data
GNU Lesser General Public License v3.0
4 stars 24 forks source link

add str and show methods #145

Closed pfuehrlich-pik closed 1 year ago

pfuehrlich-pik commented 1 year ago

str output before:

> str(maxample('pop'))
Formal class 'magpie' [package "magclass"] with 1 slot
  ..@ .Data: num [1:10, 1:16, 1:2] 553 1281 554 276 452 ...
  .. ..- attr(*, "dimnames")=List of 3
  .. .. ..$ i       : chr [1:10] "AFR" "CPA" "EUR" "FSU" ...
  .. .. ..$ t       : chr [1:16] "y1995" "y2005" "y2015" "y2025" ...
  .. .. ..$ scenario: chr [1:2] "A2" "B1"
  ..$ dim     : int [1:3] 10 16 2
  ..$ dimnames:List of 3
  .. ..$ i       : chr [1:10] "AFR" "CPA" "EUR" "FSU" ...
  .. ..$ t       : chr [1:16] "y1995" "y2005" "y2015" "y2025" ...
  .. ..$ scenario: chr [1:2] "A2" "B1"
  ..$ Metadata:List of 3
  .. ..$ unit: 'units' num 1e+06
  .. .. ..- attr(*, "units")=List of 2
  .. .. .. ..$ numerator  : chr "people"
  .. .. .. ..$ denominator: chr(0) 
  .. .. .. ..- attr(*, "class")= chr "symbolic_units"
  .. ..$ user: chr "jpd"
  .. ..$ date: chr "2018-01-15 14:19:27"

str output with this PR:

  > str(maxample('pop'))
A magpie object (package: magclass)
 @ .Data:  num [1:320] 553 1281 554 276 452 ...
 $ dimnames:List of 3
  ..$ i       : chr [1:10] "AFR" "CPA" "EUR" "FSU" ...
  ..$ t       : chr [1:16] "y1995" "y2005" "y2015" "y2025" ...
  ..$ scenario: chr [1:2] "A2" "B1"
 $ Metadata:List of 3
  ..$ unit: 'units' num 1e+06
  .. ..- attr(*, "units")=List of 2
  .. .. ..$ numerator  : chr "people"
  .. .. ..$ denominator: chr(0) 
  .. .. ..- attr(*, "class")= chr "symbolic_units"
  ..$ user: chr "jpd"
  ..$ date: chr "2018-01-15 14:19:27"