Help me please to code....
Hello, First of all, you should _really_ try to read An Introduction to R, file R-intro.pdf that comes with every installation of R. The answer to your question is in chapter 9 Grouping, loops and conditional execution. It's the very first example: "9.2.1 Conditional execution: if statements The language has available a conditional construction of the form > if (expr_1) expr_2 else expr_3 where expr 1 must evaluate to a single logical value and the result of the entire expression is then evident." Note the "evident" bit. if(X == 0) Y <- 5/2 else Y <- 7 or, when you become more familiar with R, Y <- if(X == 0) 5/2 else 7 But do read the manual. Hope this helps, Rui Barradas Em 21-10-2012 20:03, Rlotus escreveu:
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.