This mail is continuation of my previous one. i have some raw data from
Excel which was carried to R:

data = read.delim(file="clipboard", header=T)
> data
       Date Price
1  09/01/05   365
2  09/02/05   360
3  09/03/05   360
4  09/05/05   370
5  09/06/05   370
6  09/08/05   365
7  09/09/05   365
8  09/10/05   365
9  09/12/05   365
10 09/13/05   360
11 09/14/05   360
12 09/15/05   360

and, using the input from R-help I exctracted day, month, and year, from
"Date"

year = as.numeric(format(as.Date(data[,1],"%m/%d/%y"),"%Y"))
month = as.numeric(format(as.Date(data[,1],"%m/%d/%y"),"%m"))
day = as.numeric(format(as.Date(data[,1],"%m/%d/%y"),"%d"))

Now I want to create a date-variable and put it in actual data:

library(date)
data1 = cbind(mdy.date(month, day, year), data[,-1])
> data1
       [,1] [,2]
 [1,] 16680  365
 [2,] 16681  360
 [3,] 16682  360
 [4,] 16684  370
 [5,] 16685  370
 [6,] 16687  365
 [7,] 16688  365
 [8,] 16689  365
 [9,] 16691  365
[10,] 16692  360
[11,] 16693  360
[12,] 16694  360

However this is not that thing what I wanted, first column has been jumbled,
it is not in actual date format.

Can anyone tell me what should i do here?

Regards,






On 9/18/07, Arun Kumar Saha <arun.kumar.saha@gmail.com> wrote:
>
> Dear all,
>
> I have a variable 'x' like that:
>
> > x
> [1] "2005-09-01"
>
> Here, 2005 represents year, 09 month and 01 day.
>
> Now I want to create three variables naming: y, m, and d such that:
>
> y = 2005
> m = 09
> d = 01
>
> can anyone tell me how to do that?
>
> Regards,
>
>

	[[alternative HTML version deleted]]

