[R] loop causes syntax error in print()

Ivan Baxter ibaxter at purdue.edu
Tue Jul 3 07:59:45 CEST 2007


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.

...[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"  

-- 
**************************************************************
Ivan Baxter
Research Scientist
Bindley Bioscience Center
Purdue University
Office: Hort 305
765-543-7288
ibaxter at purdue.edu



More information about the R-help mailing list