[Rd] rownames for as.matrix.zoo

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Fri Apr 7 19:48:51 CEST 2006


On Fri, 7 Apr 2006 16:09:53 +0200  Brandt, T. (Tobias) wrote:

> Hi
>  
> Is there a reason why as.matrix.zoo doesn't set the rownames to the
> index like as.data.frame.zoo does?

Yes, oversight, I think ;-)

Added to the devel-version of zoo. I'll try to get it out to CRAN in
the next days.
Z

> Thanks
>  
> Tobias
>  
>  
> > library(zoo)
> > x.Date <- as.Date("2003-02-01") + c(1, 3, 7, 9, 14) - 1
> > x <- zoo(matrix(1:10, nc=2), x.Date)
> > colnames(x) <- c('A','B')
> > print(x)
>            A  B 
> 2003-02-01  1  6
> 2003-02-03  2  7
> 2003-02-07  3  8
> 2003-02-09  4  9
> 2003-02-14  5 10
> > as.data.frame(x)
>            A  B
> 2003-02-01 1  6
> 2003-02-03 2  7
> 2003-02-07 3  8
> 2003-02-09 4  9
> 2003-02-14 5 10
> > as.matrix(x)
>      A  B
> [1,] 1  6
> [2,] 2  7
> [3,] 3  8
> [4,] 4  9
> [5,] 5 10
> > R.version
>          _              
> platform i386-pc-mingw32
> arch     i386           
> os       mingw32        
> system   i386, mingw32  
> status                  
> major    2              
> minor    2.0            
> year     2005           
> month    10             
> day      06             
> svn rev  35749          
> language R              
> > library(help=zoo)
> > 
>                 Information on package 'zoo'
>  
> Description:
>  
> Package:       zoo
> Version:       1.0-2
> Date:          2005-09-07
> Title:         Z's ordered observations
> Author:        Achim Zeileis, Gabor Grothendieck
> Maintainer:    Achim Zeileis <Achim.Zeileis at R-project.org
> <mailto:Achim.Zeileis at R-project.org> >
> Description:   An S3 class with methods for totally ordered indexed
> observations. It is particularly
>                aimed at irregular time series of numeric
> vectors/matrices and factors. zoo's key
>                design goals are independence of a particular
> index/date/time class and consistency
>                with with ts and base R by providing methods to extend
> standard generics.
> Depends:       R (>= 2.1.0)
> Suggests:      chron, fCalendar, its, tseries, strucchange, DAAG
> License:       GPL
> Packaged:      Thu Sep 8 13:07:59 2005; zeileis
> Built:         R 2.1.1; ; 2005-09-09 12:21:08; windows
>  
>  
> 
> ********************
> Nedbank Limited Reg No 1951/000009/06. The following link displays
> the names of the Nedbank Board of Directors and Company Secretary.
> [ http://www.nedbank.co.za/terms/DirectorsNedbank.htm ] This email is
> confidential and is intended for the addressee only. The following
> link will take you to Nedbank's legal notice.
> [ http://www.nedbank.co.za/terms/EmailDisclaimer.htm ]
> ********************
>



More information about the R-devel mailing list