How can I get a single attribute value of an object ? I jhave the tiemSeries object> ts1Open 2003-10-09 02:00:00 1.27 2003-10-10 02:00:00 1.25 2003-10-13 02:00:00 1.27 2003-10-14 02:00:00 1.29 When I unclass ts1 I get:> unclass(ts1)list() attr(,"Data") Open 2003-10-09 02:00:00 1.27 2003-10-10 02:00:00 1.25 2003-10-13 02:00:00 1.27 2003-10-14 02:00:00 1.29 attr(,"positions") [1] "2003-10-09 02:00:00" "2003-10-10 02:00:00" "2003-10-13 02:00:00" [4] "2003-10-14 02:00:00" attr(,"format") [1] "%Y-%m-%d %H:%M:%S" attr(,"FinCenter") [1] "Zurich" attr(,"units") [1] "Open" attr(,"title") [1] "Time Series Object" attr(,"documentation") [1] "Created at Zurich 2004-12-13 15:13:05" How can I get teh value of the attribute positions?
Omar Lakkis <abu3ammar at gmail.com> writes:> > unclass(ts1) > list()....> attr(,"positions") > [1] "2003-10-09 02:00:00" "2003-10-10 02:00:00" "2003-10-13 02:00:00" > [4] "2003-10-14 02:00:00"..........> > How can I get teh value of the attribute positions?The output is providing a rather strong hint: attr(ts1, "positions") -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Since I'm not sure what you are trying to achieve would ts1 at positions get what you wanted without unclassing the object. I only ask this because my first instinct when I started using the Rmetrics package was to try and use ts1$positions which only gives you a null value. Tom> -----Original Message----- > From: Omar Lakkis [mailto:abu3ammar at gmail.com] > Sent: Tuesday, 14 December 2004 4:10 AM > To: r-help at stat.math.ethz.ch > Subject: [R] read attribute > > > How can I get a single attribute value of an object ? > > I jhave the tiemSeries object > > ts1 > Open > 2003-10-09 02:00:00 1.27 > 2003-10-10 02:00:00 1.25 > 2003-10-13 02:00:00 1.27 > 2003-10-14 02:00:00 1.29 > > When I unclass ts1 I get: > > unclass(ts1) > list() > attr(,"Data") > Open > 2003-10-09 02:00:00 1.27 > 2003-10-10 02:00:00 1.25 > 2003-10-13 02:00:00 1.27 > 2003-10-14 02:00:00 1.29 > attr(,"positions") > [1] "2003-10-09 02:00:00" "2003-10-10 02:00:00" "2003-10-13 02:00:00" > [4] "2003-10-14 02:00:00" > attr(,"format") > [1] "%Y-%m-%d %H:%M:%S" > attr(,"FinCenter") > [1] "Zurich" > attr(,"units") > [1] "Open" > attr(,"title") > [1] "Time Series Object" > attr(,"documentation") > [1] "Created at Zurich 2004-12-13 15:13:05" > > How can I get teh value of the attribute positions? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > R-project.org/posting-guide.html >