Re: [R] 'Date' elements within a matrix

2011-03-13 Thread Bogaso Christofer
: [R] 'Date' elements within a matrix On Fri, Mar 11, 2011 at 4:15 PM, Bogaso Christofer bogaso.christo...@gmail.com wrote: Dear all, when I put date objects (class of 'Date') in a matrix it becomes numeric: dat - matrix(seq(as.Date(2011-01-01), as.Date(2011-01-09), by=1 day), 3) dat

Re: [R] 'Date' elements within a matrix

2011-03-13 Thread David Winsemius
to some simpler class if it placed within a matrix? Thanks and regards, -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: 12 March 2011 02:46 To: Bogaso Christofer Cc: r-help@r-project.org Subject: Re: [R] 'Date' elements within a matrix On Fri, Mar 11

Re: [R] 'Date' elements within a matrix

2011-03-13 Thread Gabor Grothendieck
On Sun, Mar 13, 2011 at 11:46 AM, Bogaso Christofer bogaso.christo...@gmail.com wrote: Thanks everyone for clarifying my query. However I was wondering why that Date character is not preserved within a matrix? Why R forcefully changes that to numeric? I am especially concerned because as per

[R] 'Date' elements within a matrix

2011-03-11 Thread Bogaso Christofer
Dear all, when I put date objects (class of 'Date') in a matrix it becomes numeric: dat - matrix(seq(as.Date(2011-01-01), as.Date(2011-01-09), by=1 day), 3) dat [,1] [,2] [,3] [1,] 14975 14978 14981 [2,] 14976 14979 14982 [3,] 14977 14980 14983 class(dat[1,1]) [1] numeric As

Re: [R] 'Date' elements within a matrix

2011-03-11 Thread Phil Spector
It will be difficult or impossible to store objects of class Date in a matrix -- you'll need to store them in a data frame: pts = seq(as.Date(2011-01-01), as.Date(2011-01-09), by=1 day) z = data.frame(pts[1:3],pts[4:6],pts[7:9]) z pts.1.3. pts.4.6. pts.7.9. 1 2011-01-01 2011-01-04

Re: [R] 'Date' elements within a matrix

2011-03-11 Thread Gabor Grothendieck
On Fri, Mar 11, 2011 at 4:15 PM, Bogaso Christofer bogaso.christo...@gmail.com wrote: Dear all, when I put date objects (class of 'Date') in a matrix it becomes numeric: dat - matrix(seq(as.Date(2011-01-01), as.Date(2011-01-09), by=1 day), 3) dat      [,1]  [,2]  [,3] [1,] 14975 14978

Re: [R] 'Date' elements within a matrix

2011-03-11 Thread jim holtman
It is easy to recover the date by using as.Date: dat - matrix(seq(as.Date(2011-01-01), as.Date(2011-01-09), by=1 day), 3) dat [,1] [,2] [,3] [1,] 14975 14978 14981 [2,] 14976 14979 14982 [3,] 14977 14980 14983 str(dat) num [1:3, 1:3] 14975 14976 14977 14978 14979 ... as.Date(dat)