[Rd] lapply(ts(1:2), length) inconsistent answers

Spencer Graves spencer.graves at prodsyse.com
Mon Oct 21 08:39:53 CEST 2013


Hello, All:


       I'm getting different answers from "lapply(ts(1:2), length)", 
depending on what is attached, with nothing obviously masked.


             1.  Am I correct that the answer to "lapply(ts(1:2), 
length)" should be a list of length 2 consisting of "int 1" twice? This 
is what I get from R 3.0.2 with nothing else attached.  If I've attached 
other things including mar1s and a version of fda prior to the current 
2.4.0 on CRAN, I get a list of length 1 consisting of "int 2".  See below.


              2.  What might cause this inconsistency?  I'm guessing 
this may be due to something strange in the NAMESPACE, but I wouldn't 
now what.


       Thanks,
       Spencer Graves


# FROM R 3.0.2 ALONE:

 > sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] sos_1.3-8  brew_1.0-6
 > lapply(ts(1:2), length)
[[1]]
[1] 1

[[2]]
[1] 1

###############################

# FROM R 3.0.2 AFTER attach(fda), with a version between 2.3.8 and 2.4.0 
but closer for this purpose to 2.3.8:

  lapply(ts(1:2), length)
[[1]]
[1] 2

Browse[2]> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

loaded via a namespace (and not attached):
  [1] chron_2.3-44    cmrutils_1.2-2  fda_2.4.0       grid_3.0.2
  [5] lattice_0.20-24 mar1s_2.0-1     Matrix_1.0-14   splines_3.0.2
  [9] tools_3.0.2     zoo_1.7-10


##*** NOTE:  This says fda_2.4.0.  However, I believe that's an error:  
With this session open and with fda 2.3.9 attached, I did "R CMD INSTALL 
fda_2.4.0.tar.gz".  The open session seemed to use fda 2.3.9, generating 
the inconsistent behavior documented above;  I finally simplified it to 
the form here.  I believe that sessionInfo() got the version number not 
from the version it was actually using but from the latest installed 
version, which in this case is different.



More information about the R-devel mailing list