Re: [R] Using if, else statements

2008-07-23 Thread Gabriela Cendoya
t;wed","thu","fri","sat","sun") my.df$NewAdm <- my.df$admissions * weight[as.character(my.df$d.o.w)] my.df Gabriela - Original Message ----- From: "Robin Williams" <[EMAIL PROTECTED]> To: Sent: Wednesday, July 23, 2008 12:44

Re: [R] Using if, else statements

2008-07-23 Thread milton ruser
Just to clarify, if you have two data.frame, one with your data, other with data-admissions, just use data.merge<-merge(my.df, data.weigth, by.x="data", by.y="data", all=T) miltinho On 7/23/08, milton ruser <[EMAIL PROTECTED]> wrote: > > Hi Rob Williams > > I think it is one way of you do the j

Re: [R] Using if, else statements

2008-07-23 Thread milton ruser
Hi Rob Williams I think it is one way of you do the job. Cheers, miltinho astronauta brazil my.df<-data.frame(cbind(data=sample(c("mon","sat","sun"), 20, replace=T), values=rnorm(20))) my.df$values<-as.numeric(my.df$values) data.weigth<-read.table(stdin(), head=T, sep=",") data,weigt

Re: [R] Using if, else statements

2008-07-23 Thread Patrick Burns
atistical package. Any code much appreciated. -Original Message- From: Patrick Burns [mailto:[EMAIL PROTECTED] Sent: 23 July 2008 17:44 To: Robin Williams Subject: Re: [R] Using if, else statements You might have found 'ifelse' in S Poetry, which is one way of solving your problem.

Re: [R] Using if, else statements

2008-07-23 Thread jim holtman
One more try and I quit: This is what happens if someone does not sent a sample of data you have to create things on the fly without testing. days <- list(list("Sat", 1.21), list("Sun", 1.22), list("Mon", 0.91)) for (i in days){ .subset <- data$d.o.w == i[[1]] # subset of data that matches

Re: [R] Using if, else statements

2008-07-23 Thread jim holtman
My fingers slipped on the keyboard. Here what they intended to write. This sets up a list of the data and the matches on a subset for processing days <- list(list("Sat", 1.21), list("Sun", 1.22), list("Mon", 0.91)) for (i in days){ .subset <- data$d.o.w == i[[1]] # subset of data that matc

Re: [R] Using if, else statements

2008-07-23 Thread jim holtman
You would have something that looks like this: if (data$d.o.w == "Sat") data$admission <- round(data$admission * 1.21) if (data$d.o.w == "Sun") ... On Wed, Jul 23, 2008 at 11:44 AM, Robin Williams <[EMAIL PROTECTED]> wrote: > Hi all, > > Again I have searched the net and so on, without find

[R] Using if, else statements

2008-07-23 Thread Robin Williams
Hi all, Again I have searched the net and so on, without finding an answer to this surely simple problem. A short bit of code would be appreciated. I have a object named `data' with the following column headings. Date, maxitemp, minitemp, admissions, d.o.w. Where d.o.w. is day of the week,