[R] Strange parsing behavior of an else condition
Christian Lederer
rsubscriber at slcmsr.net
Tue Feb 8 05:09:57 CET 2005
Dear R users,
can anybody explain the reason, why the first piece of code
below gives a parsing error, while the other two variations
work?
# Gives a parsing error
x <- 1
if (x < 0)
{
y <- 1
}
else # Error occurs at this line
{
y <- -1
}
# This works
x <- 1
{
if (x < 0)
{
y <- 1
}
else
{
y <- -1
}
}
# This works too
x <- 1
if (x < 0)
{
y <- 1
} else
{
y <- -1
}
Christian
More information about the R-help
mailing list