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 finding an
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 matches
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
: 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.
Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home
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 job.
Hi Robin:
I think you can avoid the loops doing this:
my.df-data.frame(d.o.w=sample(c(mon,sat,sun), 20, replace=T),
admissions=rnorm(20))
weight - c(1,1,1,1,1,1.21,1.22)
names(weight) - c(mon,tue,wed,thu,fri,sat,sun)
my.df$NewAdm - my.df$admissions *
6 matches
Mail list logo