[R] Help me please to code....

arun smartpink111 at yahoo.com
Sun Oct 21 22:05:56 CEST 2012


HI,
Try this:
fun1<-function(X){
 Y<-ifelse(X==0,5/2,7)
 return(Y)}
 fun1(5)
#[1] 7
 fun1(0)
#[1] 2.5
 fun1(2)
#[1] 7
A.K.





----- Original Message -----
From: Rlotus <yerlan_ at hotmail.com>
To: r-help at r-project.org
Cc: 
Sent: Sunday, October 21, 2012 3:03 PM
Subject: [R] Help me please to code....

User has to type (input) x.  After input....code has to check X with
statement if

There is a statement IF. 

If X=0 then Y=5/2 else =7;

How to code it please. I tried but my code does not work ;( I wanna see how
it looks like( thank u in advance(



--
View this message in context: http://r.789695.n4.nabble.com/Help-me-please-to-code-tp4646932.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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