[R] loop causes syntax error in print()
Duncan Murdoch
murdoch at stats.uwo.ca
Tue Jul 3 14:48:49 CEST 2007
On 7/3/2007 1:59 AM, Ivan Baxter wrote:
> I am having trouble printing a table out to the GUI display when the
> table is created and printed within a loop.
>
> I get a "Error: syntax error message"
>
> If I comment out the print statement, the loop runs fine and I can print
> out the last iteration of the table.
You should simplify your loop until it's something you can post for us
to try. Chances are you'll notice the error when you do that, but if
not, someone else will be able to tell you what's going on.
Without a reproducible example, it's more or less hopeless.
Duncan Murdoch
>
> ...[multiple loops and calculations ending with.....]...
>
> + print(paste(mutType,"sim",sim,"hmm",hmm))
> + # print(acctab[,10:15])
> +
> + nummod <- nummod +1
> + } #end hmmMats loop
> + } #end tmats loop
> + } #end mut type loop
> [1] "dup sim Imod hmm Jmod"
>
> > print(acctab[,10:15])
> hitrate falsepos multrate avghit avgmiss avgfalsepos
> 1 0.0000000 1 NaN NaN 2 NA
> 2 1.0000000 0 0.00000000 5.333333 NaN NA
> 3 0.0000000 NaN NaN NaN 9 NA
> 4 0.7777778 0 0.00000000 15.571429 11 NA
> 5 1.0000000 0 0.00000000 24.083333 NaN NA
> 6 1.0000000 0 0.07692308 64.538462 NaN NA
> 7 1.0000000 0 0.39207048 1088.454846 NaN NA
>
> you can see that
> a) the print statement above it works
> b) the print command works with this table
>
> but if I uncomment it and try to run the loops again.....
>
> + print(paste(mutType,"sim",sim,"hmm",hmm))
> print(acctab[,10:15])
> Error: syntax error
> >
> >
> > nummod <- nummod +1
> > } #end hmmMats loop
> Error: syntax error
> > } #end tmats loop
> Error: syntax error
> > } #end mut type loop
> Error: syntax error
>
>
> I have tried print.data.frame, but that doesn't work either....
>
>
> Any suggestions would be appreciated (session info below)
>
>
> Ivan
>
>
> > sessionInfo()
> R version 2.5.1 (2007-06-27)
> i386-apple-darwin8.9.1
>
> locale:
> C
>
> attached base packages:
> [1] "stats" "graphics" "grDevices" "utils" "datasets"
> "methods" "base"
>
More information about the R-help
mailing list