Because the line if... Is syntactically complete. Move the else statement to the line above it like
tclass <- "Testing 1 2 3" if ( tclass == "Testing 1 2 3" ) { cat ( "Testing" , tclass , "\n" ) } else { cat ( tclass , "\n" ) } david -- David ----------------------------------------------------- David Huffer, Ph.D. Senior Statistician CSOSA/Washington, DC david.huf...@csosa.gov ----------------------------------------------------- -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of rkevinbur...@charter.net Sent: Monday, August 03, 2009 4:41 PM To: r-help@r-project.org Subject: [R] if confusion Simple question: Why doesn't the following work? Or what 'R' rule am I missing? tclass <- "Testing 1 2 3" if(tclass == "Testing 1 2 3") { cat("Testing", tclass, "\n") } else { cat(tclass, "\n") } I get an error 'else' is unexpected. Thank you. Kevin ______________________________________________ R-help@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. ______________________________________________ R-help@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.