Re: [R] How can we creat conditional data frame

2008-04-04 Thread saikat sarkar
Here is the solution data<-read.table("d:/ftse.txt",header=TRUE) wDay<-as.Date(data$date,"%d/%m/%Y") data<-data.frame(data[,-1]) price<-data$ftse100 data<-data.frame(price,wDay) data[1:10,] a<-as.Date("03/01/1989","%d/%m/%Y") b<-as.Date("31/01/2007","%d/%m/%Y") ab<-seq(a,b,by=1) c<-

Re: [R] How can we creat conditional data frame

2008-04-04 Thread bartjoosen
Hello, altough I'm not an expert, I found a solution (maybe not the most elegant.) d<-as.Date(c("2000/01/03","2000/01/05","2000/01/19","2000/01/28")) r<-rnorm(4) da<-data.frame(d,r) a<-as.Date("01/01/2000","%d/%m/%Y") b<-as.Date("30/01/2000","%d/%m/%Y") ab<-seq(a,b,by=1) c<-format(ab,

Re: [R] How can we creat conditional data frame

2008-04-04 Thread Gabor Grothendieck
The last line should have been: z <- merge(r = tmp.z, weekday = as.numeric(format(time(date.z), "%w")), h = !tmp.z) On Fri, Apr 4, 2008 at 8:25 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Have a look at the zoo package. After reading > in the data its only 2 lines of code. > > Not

Re: [R] How can we creat conditional data frame

2008-04-04 Thread Henrique Dallazuanna
If I understand: res <- merge(date, da, by.x = "ab", by.y="d", all=T) res$h <- 0 res$h[is.na(res$r)] <- 1 res$r[is.na(res$r)] <- 0 On Fri, Apr 4, 2008 at 8:49 AM, saikat sarkar <[EMAIL PROTECTED]> wrote: > > Hi, > > R experts. I am a new user of R and trying to learn this program. > > I have a

Re: [R] How can we creat conditional data frame

2008-04-04 Thread Gabor Grothendieck
Have a look at the zoo package. After reading in the data its only 2 lines of code. Note that zoo objects can be numeric or factor but not both so we have represented the day of the week as 1 for Mon, etc. in the final object. You could convert it to a data frame at the end if you really need t

[R] How can we creat conditional data frame

2008-04-04 Thread saikat sarkar
Hi, R experts. I am a new user of R and trying to learn this program. I have a problem. Here is the code. d<-as.Date(c("2000/01/03","2000/01/05","2000/01/19","2000/01/28")) r<-rnorm(4) da<-data.frame(d,r) a<-as.Date("01/01/2000","%d/%m/%Y") b<-as.Date("30/01/2000","%d/%m/%Y") ab<-seq(a,b,by=

[R] How can we creat conditional data frame

2008-04-04 Thread saikat sarkar
Hi, R experts. I am a new user of R and trying to learn this program. I have a problem. Here is the code. d<-as.Date(c("2000/01/03","2000/01/05","2000/01/19","2000/01/28")) r<-rnorm(4) da<-data.frame(d,r) a<-as.Date("01/01/2000","%d/%m/%Y") b<-as.Date("30/01/2000","%d/%m/%Y") ab<-seq(a,b,by=