Skip to content

(no subject)

1 message · arun

#
Hi Dila,
Try:

transform(melt(dat,id.var="Day"),Month=match(variable,month.abb),Year=2012,Amount=value)[,-c(2:3)]

A.K.
On Tuesday, February 25, 2014 11:41 PM, dila radi <dilaradi21 at gmail.com> wrote:
Dear Arun,

sorry for asking again.

Assume that we used the sama data set?

dat <- read.table(text="Day Jan Feb Mar Apr
? 1 0 2.5 0.5 2
? 2 0 6.5 0 29
? 3 0 9.5 0 0
? 4 0 0 8 0.5
? 5 0 5 0.5 110.5
? 6 0 4 3.5 22
? 7 11 0 12.5 3.5
? 8 0 5 8 36.5",sep="",header=TRUE)



But now, I want to split the date into Day, Month and Year as follow:

Day ? ? ? Month ? ? ? ? ? Year ? ? ?Amount
? 1 ? ? ? ? ? ? 1 ? ? ? ? ? ? ? 2012 ? ? ? 0.0
? ?2 ? ? ? ? ? ?1 ? ? ? ? ? ? ? 2012 ? ? ? 0.0
? 3 ? ? ? ? ? ? 1 ? ? ? ? ? ? ? 2012 ? ? ? 0.0
....................
..................

How do I?achieved?that? Thank you so much.

Regards,
Dila ?
On 24 February 2014 20:32, arun <smartpink111 at yahoo.com> wrote: