[R] list with element "Class 'Date' num"

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Fri Apr 7 17:50:33 CEST 2017


On Thu, 6 Apr 2017, Tintin wrote:

> Hi
>
> How do I create an element with specificiation " Class 'Date' num "
>
> The problem arises when I try to construct my own data structure set in the
> "termstrc" package. The model list should look like:
>
> R> str(govbonds$GERMANY)
> List of 8
> $ ISIN
> : chr [1:52] "DE0001141414" "DE0001137131" "DE0001141422" ...
> $ MATURITYDATE:Class ' Date ' num [1:52] 13924 13952 13980 14043 ...
> $ ISSUEDATE
> :Class ' Date ' num [1:52] 11913 13215 12153 13298 ...
> $ COUPONRATE : num [1:52] 0.0425 0.03 0.03 0.0325 ...
> $ PRICE
> : num [1:52] 100 99.9 99.8 99.8 ...
> $ ACCRUED
> : num [1:52] 4.09 2.66 2.43 2.07 ...
> $ CASHFLOWS
> :List of 3
> ..$ ISIN: chr [1:384] "DE0001141414" "DE0001137131" "DE0001141422" ...
> ..$ CF : num [1:384] 104 103 103 103 ...
> ..$ DATE:Class ' Date ' num [1:384] 13924 13952 13980 14043 ...
> $ TODAY
> :Class ' Date ' num 13908
>
> I am trying to create my own basis data.I can create list elements of the
> type "Date", but not of type " Class 'Date' num ".

a) Date objects are numeric, so this does not seem so far off target.

b) I do not get the same output from str() as you do.

#########################
> library(termstrc)
> data("govbonds")
> str(govbonds$GERMANY)
List of 8
  $ ISIN        : chr [1:52] "DE0001141414" "DE0001137131" "DE0001141422" 
"DE0001137149" ...
  $ MATURITYDATE: Date[1:52], format: "2008-02-15" "2008-03-14" 
"2008-04-11" "2008-06-13" ...
  $ ISSUEDATE   : Date[1:52], format: "2002-08-14" "2006-03-08" 
"2003-04-11" "2006-05-30" ...
  $ COUPONRATE  : num [1:52] 0.0425 0.03 0.03 0.0325 0.0413 ...
  $ PRICE       : num [1:52] 100 99.9 99.8 99.8 100.1 ...
  $ ACCRUED     : num [1:52] 4.09 2.66 2.43 2.07 2.39 ...
  $ CASHFLOWS   :List of 3
   ..$ ISIN: chr [1:384] "DE0001141414" "DE0001137131" "DE0001141422" 
"DE0001137149" ...
   ..$ CF  : num [1:384] 104 103 103 103 104 ...
   ..$ DATE: Date[1:384], format: "2008-02-15" "2008-03-14" "2008-04-11" 
"2008-06-13" ...
  $ TODAY       : Date[1:1], format: "2008-01-30"
####################

c) I observe that your output has "Class ' Date ' num", not " Class 'Date' 
num ". This suggests there might be something going on with your character 
encoding of the class name, but that could be in your email creation steps 
rather than in R. Or, it could be related to a bug in the package or in 
R... but you will need to give more info to convince anyone of those 
possibilities.

d) You may just need to update R or your packages. My configuration for 
this test was:

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

locale:
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C 
LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8 
LC_PAPER=en_US.UTF-8       LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C 
LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] termstrc_1.3.7

loaded via a namespace (and not attached):
  [1] zoo_1.7-14      sandwich_2.3-4  tools_3.3.3     Rcpp_0.12.10 
nlme_3.1-131    urca_1.3-0
  [7] grid_3.3.3      lmtest_0.9-35   rgl_0.93.996    lattice_0.20-35


---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k



More information about the R-help mailing list