[R] if block and brackets

Jason Turner jasont at indigoindustrial.co.nz
Thu Mar 25 02:39:24 CET 2004


> what is wrong with this if structure? I am
> getting an error on the line where "else" is
>
> thanks
>
>   if (exists("f")){
>     dt <- read.csv(file.path(d,f),header=F)#data frame
>     builddl(dt,f)
>   else

The block started by "if(...){" isn't complete - it needs a matching "}"
before it is.  As such, the "else" is just hanging by itself.  An "else"
with no corresponding "if" is a syntax error.  This would be correct
(UNTESTED)

if (exists("f")){
  dt <- read.csv(file.path(d,f),header=F)#data frame
  builddl(dt,f)
}
else

Cheers
Jason




More information about the R-help mailing list