[R] arrange data
arun
smartpink111 at yahoo.com
Mon Nov 12 06:29:31 CET 2012
HI,
I think it would be better to store this as a list.
For example:
list1<- list(kuantan.dt[kuantan.dt[,2]==11,],kuantan.dt[kuantan.dt[,2]==12,])
If you wanted to delete 31 December and do column bind:
res<-cbind(kuantan.dt[kuantan.dt[,2]==11,], kuantan.dt[kuantan.dt[,2]==12 & kuantan.dt[,3]!=31,]) # assuming 3rd column corresponds to day
A.K.
----- Original Message -----
From: Roslina Zakaria <zroslina at yahoo.com>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc:
Sent: Sunday, November 11, 2012 9:39 PM
Subject: [R] arrange data
Dear r-users,
I have daily rainfall data from 1971 to 2000. I would like to extract november and december data only. I would also like to do column bind for november and december, therefore I would like to delete 31 December from december data so that the length of november and december are the same. Hope somebody can help me. I tried this below:
> kuantan.dt.1 <- kuantan.dt[(kuantan.dt$Bulan >=11) & (kuantan.dt$Bulan <= 12),]
> head(kuantan.dt.1) ; tail(kuantan.dt.1)
Tahun Bulan Hari Jumlah.Hujan.mm.
305 71 11 1 0.0
306 71 11 2 16.3
307 71 11 3 0.0
308 71 11 4 0.0
309 71 11 5 12.2
310 71 11 6 4.6
Tahun Bulan Hari Jumlah.Hujan.mm.
10953 0 12 26 0.0
10954 0 12 27 0.0
10955 0 12 28 20.0
10956 0 12 29 15.5
10957 0 12 30 6.4
10958 0 12 31 9.3
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org 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.
More information about the R-help
mailing list