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
__
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
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
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
"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
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]
&
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 <=
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
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 <=
__
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
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
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
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
13 matches
Mail list logo