[R] putting a column name on a zoo object

Leeds, Mark (IED) Mark.Leeds at morganstanley.com
Tue Nov 14 22:49:24 CET 2006


I only have one column so when I try your suggestion, I get dsays,
"attempt to set colnames on object with less than two dimensions.
It is of class zoo but I guess something changes during that addition
that I am too much of a novice to understand.

This is what a dput gives. There is no dim in the dput which is probably
what the problem is but I don't know how to fix it. Thanks.


structure(c(4.77126598671015, 4.7716359319335, 4.77176152623894, 
4.77196709472722, 4.77218067995761, 4.77213077515643, 4.77200790109121, 
4.77203963822312, 4.7719973218234, 4.771903278968, 4.77183227075241, 
4.77182803831544, 4.77181216651724, 4.77182803831544, 4.77197193112401, 
4.77198938729909, 4.77201612933324, 4.77202905929107, 4.7720184802471, 
4.77188623275365, 4.77181745714463, 4.77187036187909, 4.77187036187909, 
4.77187036187909, 4.77182803831544, 4.77182803831544, 4.77174338581391, 
4.77179982161115, 4.77174338581391, 4.77182199194583, 4.77179417817475, 
4.77174338581391, 4.77174338581391, 4.77179982161115, 4.77182803831544, 
4.77182803831544, 4.77187036187909, 4.77191268365153, 4.7719338438661, 
4.77191268365153, 4.77176690111649, 4.77188094249012, 4.77189857659306, 
4.77212752040897, 4.77224143026734, 4.77240630536398), index =
structure(c(1144022520, 
1144022580, 1144022640, 1144022700, 1144022760, 1144022820, 1144022880, 
1144022940, 1144023000, 1144023060, 1144023120, 1144023180, 1144023240, 
1144023300, 1144023360, 1144023420, 1144023480, 1144023540, 1144023600, 
1144023660, 1144023720, 1144023780, 1144023840, 1144023900, 1144023960, 
1144024020, 1144024080, 1144024140, 1144024200, 1144024260, 1144024320, 
1144024380, 1144024440, 1144024500, 1144024560, 1144024620, 1144024680, 
1144024740, 1144024800, 1144024860, 1144024920, 1144024980, 1144025040, 
1144025100, 1144025160, 1144025220), class = c("POSIXt", "POSIXct"
)), class = "zoo", .Names = c("1144022520", "1144022580", "1144022640", 
"1144022700", "1144022760", "1144022820", "1144022880", "1144022940", 
"1144023000", "1144023060", "1144023120", "1144023180", "1144023240", 
"1144023300", "1144023360", "1144023420", "1144023480", "1144023540", 
"1144023600", "1144023660", "1144023720", "1144023780", "1144023840", 
"1144023900", "1144023960", "1144024020", "1144024080", "1144024140", 
"1144024200", "1144024260", "1144024320", "1144024380", "1144024440", 
"1144024500", "1144024560", "1144024620", "1144024680", "1144024740", 
"1144024800", "1144024860", "1144024920", "1144024980", "1144025040", 
"1144025100", "1144025160", "1144025220"))


-----Original Message-----
From: Leeds, Mark (IED) 
Sent: Tuesday, November 14, 2006 4:39 PM
To: 'Horace Tso'; r-help at stat.math.ethz.ch
Subject: RE: [R] putting a column name on a zoo object

 let me try colnames. I thought I tried that earlier and got an error
but I've been wrong before.
 Thanks.


-----Original Message-----
From: Horace Tso [mailto:Horace.Tso at pgn.com]
Sent: Tuesday, November 14, 2006 4:29 PM
To: Leeds, Mark (IED); r-help at stat.math.ethz.ch
Subject: Re: [R] putting a column name on a zoo object

Mark,

What's wrong with the following,

> head(sp.z)
              Open    High     Low   Close     Volume Adj..Close.
2000-01-03 1469.25 1478.00 1438.36 1455.22  931800000     1455.22
2000-01-04 1455.22 1455.22 1397.43 1399.42 1009000000     1399.42
2000-01-05 1399.42 1413.27 1377.68 1402.11 1085500032     1402.11
2000-01-06 1402.11 1411.90 1392.10 1403.45 1092300032     1403.45
2000-01-07 1403.45 1441.47 1400.73 1441.47 1225200000     1441.47
2000-01-10 1441.47 1464.36 1441.47 1457.60 1064800000     1457.60

 colnames(sp.z)
[1] "Open"        "High"        "Low"         "Close"       "Volume"   
 
[6] "Adj..Close."

> colnames(sp.z)[1] = "OPEN"

> colnames(sp.z)
[1] "OPEN"    "High"        "Low"         "Close"       "Volume"     
[6] "Adj..Close."

HTH.

Horace W. Tso

 


>>> "Leeds, Mark (IED)" <Mark.Leeds at morganstanley.com> 11/14/2006
1:21:33 PM >>>
does anyone know how to put a column name on a zoo object. I think achim
and gabor are off line or they have gotten totally tired of me an
decided to ignore me ( which is totalyy understandable ).

logbidask<-log((aggfxdata[,"bid"] + aggfxdata[,"ask"])/2.0) logbidask
doesn't have a name and I can't figure out how to get one on it ?

aggfxdata is a zoo object.
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to
buy/se...{{dropped}}

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}



More information about the R-help mailing list