Skip to content
Back to formatted view

Raw Message

Message-ID: <B393C191-9B9B-44DC-8459-1CC64527AC72@comcast.net>
Date: 2012-02-09T16:54:06Z
From: David Winsemius
Subject: ifelse
In-Reply-To: <A12872756FAB8042A67B0B286A9FB21503155C9C@aismsx.a-i-s.biz>

On Feb 9, 2012, at 11:37 AM, Arnaud Gaboury wrote:

> Hello,
>
> I need to print a screen message after a test.
>
>> list<-c("10","1","100","10")
>> ifelse(all(list %in% c(1,10,100)==TRUE),cat("YES\n"),cat("NO\n"))
> YES
> Error in ifelse(all(l %in% c(1, 10, 100) == TRUE), cat("YES\n"),  
> cat("NO\n")) :
>  replacement has length zero
>
>
> I have the correct answer, YES, but with an Error.
>
> Why?

cat() returns NULL. Why ar enou not just returning the strings  
themselves or if you want to see the results as well as assign, then  
use print() which does return its arguments.


>
> TY for any help
>
>
> Arnaud Gaboury
>
> A2CT2 Ltd.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT