An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20060206/f85c01b0/attachment.pl
problem with simple if() statement
7 messages · Norman Goodacre, Alexandre Santos Aguiar, Philippe GROSJEAN +3 more
Norman Goodacre wrote:
the following code apprantely, for some grand old reason, induces a syntax error: if (seq[i] = "A") m <- trans[1,] where seq is a vector and trans is a matrix. I cannot for the life of me see why this is wrong. Syntax error is: Error: syntax error in "if (seq[i] ="
I guess you mean "==" .... Uwe Ligges
Sincerely, Norman Goodacre --------------------------------- --------------------------------- [[alternative HTML version deleted]]
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Em Seg 06 Fev 2006 04:22, Norman Goodacre escreveu:
if (seq[i] = "A") m <- trans[1,]
I'll guess that it is the use you are making of the name 'seq'. :-) 'seq' is an R function. Try some other name.
Alexandre
Norman Goodacre wrote:
the following code apprantely, for some grand old reason, induces a syntax error: if (seq[i] = "A") m <- trans[1,] where seq is a vector and trans is a matrix. I cannot for the life of me see why this is wrong. Syntax error is: Error: syntax error in "if (seq[i] =" Sincerely, Norman Goodacre
Please, read "An Introduction to R" provided with any version of R. The correct syntax for an equality condition is "==", not "=", so: > if (seq[i] == "A") .... Best, Philippe Grosjean
3 days later
Hi Norman ! I observe that R syntax is very close to C/C++ or Java --- Philippe Grosjean <phgrosjean at sciviews.org> a ??crit??:
Norman Goodacre wrote:
the following code apprantely, for some grand old
reason, induces a syntax error:
if (seq[i] = "A") m <- trans[1,] where seq is a vector and trans is a matrix. I
cannot for the life of me see why this is wrong. Syntax error is:
Error: syntax error in "if (seq[i] =" Sincerely, Norman Goodacre
Please, read "An Introduction to R" provided with any version of R. The correct syntax for an equality condition is "==", not "=", so:
> if (seq[i] == "A") ....
Best, Philippe Grosjean
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
2 days later
Evidently, my R has some feature of error messages disabled.
"NG" == Norman Goodacre <taranpen at yahoo.co.uk> writes:
NG> the following code apprantely, for some grand old reason, induces a syntax error: NG> if (seq[i] = "A") m <- trans[1,] NG> Error: syntax error in "if (seq[i] =" Where Norman gets this nice error message pointing to the exact location of the error, all I get is:
if (1=1) 5
Error: syntax error
How do I turn on more-verbose error messages? Is this an environmental
issue, or a build issue?
This is a debian (ubuntu breezy) build; happens even when I run R --vanilla
R.version
_
platform i486-pc-linux-gnu
arch i486
os linux-gnu
system i486, linux-gnu
status
major 2
minor 1.1
year 2005
month 06
day 20
language R
TIA!
Patricia J. Hawkins Hawkins Internet Applications www.hawkinsia.com
1 day later
Patricia J. Hawkins wrote:
Evidently, my R has some feature of error messages disabled.
"NG" == Norman Goodacre <taranpen at yahoo.co.uk> writes:
NG> the following code apprantely, for some grand old reason, induces a syntax error: NG> if (seq[i] = "A") m <- trans[1,] NG> Error: syntax error in "if (seq[i] =" Where Norman gets this nice error message pointing to the exact location of the error, all I get is:
if (1=1) 5
Error: syntax error How do I turn on more-verbose error messages? Is this an environmental issue, or a build issue?
It's a version issue! Please update. Uwe Ligges
This is a debian (ubuntu breezy) build; happens even when I run R --vanilla
R.version
_
platform i486-pc-linux-gnu
arch i486
os linux-gnu
system i486, linux-gnu
status
major 2
minor 1.1
year 2005
month 06
day 20
language R
TIA!