An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110413/c23cafe4/attachment.pl>
if (cond) expr1 expr2 ??
2 messages · Mohammad Tanvir Ahamed, Ista Zahn
Hi Tanvir,
Line breaks matter in R. If I understand correctly you want
for (i in 1: 4){
if(i == 2){
print("a")
print("b")
}
}
Best,
Ista
On Wed, Apr 13, 2011 at 10:07 PM, Mohammad Tanvir Ahamed
<mashranga at yahoo.com> wrote:
hi ,?this can be done easily?if (cond) expr ex:
for (i in 1: 4)+ {+ if(i==2) print("a")+ if(i==2) print("b")+ }
output :?[1] "a"[1] "b" but i want this if (cond) expr1 expr 2 i tried this :
for (i in 1: 4)+ {+ if(i==2) (print("b") && print("a"))+ }
output :?[1] "b"Error in print("b") && print("a") : invalid 'x' type in 'x && y'
but i expect the same out put as before .
i am new at R . plz help .
Thanks ,?Tanvir
? ? ? ?[[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.
Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org