Re: [R] And Statement for two if functions

2012-01-30 Thread R. Michael Weylandt
Nested if's are fine in R, but as David said you probably want ifelse(). This sounds sufficiently homework-y that I'm hesitant to give example code but it's all over the archives. Just to head off a problem I see in your pesudo-code; you're going to want to use ifelse() to construct the points vec

Re: [R] And Statement for two if functions

2012-01-30 Thread kerry1912
Sorry that post was written in a bit if a rush. I am writing a function in which I am trying to create a league table from a data frame of rugby matches with the columns as follows: home team, away team, home score and away score. In rugby you can get an extra bonus point if you are the losing te

Re: [R] And Statement for two if functions

2012-01-30 Thread David Winsemius
On Jan 30, 2012, at 9:52 AM, kerry1912 wrote: I want to perform two if functions at the same time: if(home team > away team & home team <= away team + 7) in R but i am struggling to work out how to write this correctly. Generally newcomers to the R language find that the "ifelse" function

Re: [R] And Statement for two if functions

2012-01-30 Thread Jorge I Velez
Hi kerry1912, And what exactly would you like to do after the if(...) statement? How did you read your data in? What's the output of str(yourdata)? Please see http://www.R-project.org/posting-guide.htmland help us to help you. Regards, Jorge On Mo