Re: [R] if() command

2005-09-15 Thread Petr Pikal
Hi Sorry, I am not sure why sometimes is a text from my answeres stripped off. On 14 Sep 2005 at 14:09, Carlos Mauricio Cardeal Mende wrote: > Ok Petr, I run your suggestion and I got this message: > > > age<-sample(seq(10,50,10), 20, replace=T) > > > > if (age <=10) {group <- 1} els

Re: [R] if() command

2005-09-15 Thread Petr Pikal
__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] if() command

2005-09-14 Thread Huntsinger, Reid
nt: Wednesday, September 14, 2005 1:21 PM To: Huntsinger, Reid Cc: r-help@stat.math.ethz.ch Subject: Re: [R] if() command Hello reid ! About your third explanation, could you please write the complete code including that option: a loop ? Forgiveme, I'm trying to learn R and my mind is full of oth

Re: [R] if() command

2005-09-14 Thread Roger Bivand
On Wed, 14 Sep 2005, Carlos Mauricio Cardeal Mendes wrote: > Ok Petr, I run your suggestion and I got this message: > > > age<-sample(seq(10,50,10), 20, replace=T) > > > > if (age <=10) {group <- 1} else if (age > 10 & age <= 20) {group <- > 2} else {group <- 3} > Warning message: > the condi

Re: [R] if() command

2005-09-14 Thread Sundar Dorai-Raj
"if" is not vectorised and "age" is a vector. Try the following test: if(c(TRUE, FALSE)) "TRUE" else "FALSE" You really need to use "ifelse". ifelse(c(TRUE, FALSE), "TRUE", "FALSE") As others have suggested, you might want to look at ?cut. --sundar Carlos Mauricio Cardeal Mendes wrote: > Ok P

Re: [R] if() command

2005-09-14 Thread Carlos Mauricio Cardeal Mendes
if (age <= 20) 2 else 3 >> >> > >that is, if() returns a value you can assign. > >Finally, besides "ifelse" you can use "cut" for this particular task. > >Reid Huntsinger > > >-Original Message- >From: [EMAIL PROTECTED] &

Re: [R] if() command

2005-09-14 Thread Carlos Mauricio Cardeal Mendes
Ok Petr, I run your suggestion and I got this message: > age<-sample(seq(10,50,10), 20, replace=T) > > if (age <=10) {group <- 1} else if (age > 10 & age <= 20) {group <- 2} else {group <- 3} Warning message: the condition has length > 1 and only the first element will be used in: if (age <=

Re: [R] if() command

2005-09-13 Thread Huntsinger, Reid
nal Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Carlos Maurício Cardeal Mendes Sent: Tuesday, September 13, 2005 9:29 AM To: r-help@stat.math.ethz.ch Subject: [R] if() command Hi everyone ! Could you please help me with this problem ? I´ve trying to write a code

Re: [R] if() command

2005-09-13 Thread Petr Pikal
Hallo On 13 Sep 2005 at 10:29, Carlos Maurício Cardeal Mende wrote: > Hi everyone ! > > Could you please help me with this problem ? > > I´ve trying to write a code that assign to a variable the content from > another, but all I´ve got is a message error. For example: > > if (age <=

Re: [R] if() command

2005-09-13 Thread Petr Pikal
__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] if() command

2005-09-13 Thread vincent
not enough parenthesis hih __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] if() command

2005-09-13 Thread Sundar Dorai-Raj
Carlos Maurício Cardeal Mendes wrote: > Hi everyone ! > > Could you please help me with this problem ? > > I´ve trying to write a code that assign to a variable the content from > another, but all I´ve got is a message error. For example: > > if (age <=10) {group == 1} > else if (age > 10 & a

[R] if() command

2005-09-13 Thread Carlos Maurício Cardeal Mendes
Hi everyone ! Could you please help me with this problem ? I´ve trying to write a code that assign to a variable the content from another, but all I´ve got is a message error. For example: if (age <=10) {group == 1} else if (age > 10 & age <= 20) {group == 2} else {group == 3} Syntax error Or