[R] Can we interlink these three if conditions?

MacQueen, Don macqueen1 at llnl.gov
Tue Aug 14 22:08:42 CEST 2012


Perhaps you are looking for this?

if  () {
  ## whatever
} else if () {
  ## whatever
} else if () {
  ## whatever
} else {
  cat('none of the conditions was met\n')
}

Suggestion: study this example to see that your first if() condition is
more complicated than necessary

> if (identical(1,1) == 'TRUE') cat('what\n')
what

> if (identical(1,1)) cat('what\n')
what

-Don


-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 8/13/12 10:54 PM, "Sri krishna Devarayalu Balanagu"
<balanagudevarayulu at gvkbio.com> wrote:

>key1.=c(1, 2, 3)
>key2.=c(2)
>
>if (identical(key1.,key2.) == "TRUE")     {
>                  
>      cat("No Errors found")
>                                                                }
>
>if (length(setdiff(key1., key2.)) !=0)    {
>                  
>      cat("Reference.ID_Trial.ID_Arm.ID_SubArm.ID\n\n")
>                  
>      cat(paste(setdiff(key1., key2.)), sep="\n")
>                  
>      cat("Error Message: The above value is not found in key2.\n\n")
>                                                                }
>if (length(setdiff(key2., key1.)) !=0)        {
>                  
>      cat("Reference.ID_Trial.ID_Arm.ID_SubArm.ID\n\n")
>                  
>      cat(paste(setdiff(key2., key1.)), sep="\n")
>                  
>      cat("Error Message: The above value is not found in key1.\n\n")
>                                                                }
>________________________________
>Notice: The information contained in this electronic mail message is
>intended only for the use of the designated recipient. This message is
>privileged and confidential. and the property of GVK BIO or its
>affiliates and subsidiaries. If the reader of this message is not the
>intended recipient or an agent responsible for delivering it to the
>intended recipient, you are hereby notified that you have received this
>message in error and that any review, dissemination, distribution, or
>copying of this message is strictly prohibited. If you have received this
>communication in error, please notify us immediately by telephone
>+91-40-66929999<tel:%2B91-40-66929999> and destroy any and all copies of
>this message in your possession (whether hard copies or electronically
>stored copies).
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>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.



More information about the R-help mailing list