R-alpha: [ ] and attributes

Paul Gilbert (pgilbert@bank-banque-canada.ca)
Wed, 29 May 1996 14:26:34 -0400


Date: Wed, 29 May 1996 14:26:34 -0400
From: pgilbert@bank-banque-canada.ca (Paul Gilbert)
To: ihaka@stat.auckland.ac.nz
Subject: R-alpha: [ ] and attributes
Message-Id: <96May29.141402edt.29448@mailgate.bank-banque-canada.ca>


In S, when a subset of a matrix is selected with [] then it seems that
all attributes other than $dim are removed, whereas in R the other
attributes are not removed (in 0.7). This is causing me some difficuly,
as my tframe sets an attribute to indicate time information. If
the attribute is not stripped then time frame information remains and
is no longer consistent with the data. Is it intended that attributes
should not be stripped in R or is this a bug?

Paul

R:
>  tspvector <- ts(1:100, start=c(1981,3), frequency=4)
> data <- matrix(rnorm(300),100,3)
>  tframe(data) <- tframe(tspvector)   
>  z <- data[10:90,]
> periods(z)
[1] 100
> attributes(z)
$dim
[1] 81  3

$tframe
[1] 1981.50 2006.25    4.00
attr($tframe,"class")
[1] "ts"     "tframe"


S:
> tspvector <- ts(1:100, start=c(1981,3), frequency=4)
> data <- matrix(rnorm(300),100,3)
>  tframe(data) <- tframe(tspvector)   
>  z <- data[10:90,]
>  attributes(z)
$dim:
[1] 81  3

> 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-