[R] loop causes syntax error in print()

Duncan Murdoch murdoch at stats.uwo.ca
Tue Jul 3 17:20:50 CEST 2007


On 7/3/2007 10:23 AM, Ivan Baxter wrote:
> 
> Duncan Murdoch wrote:
>> 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
> Right- well I did as you suggested and seem to have fixed the problem.
> 
> The problem appeared to be that some carriage returns were not 
> registering in the Mac Os X R editor. So even though it looked like it 
> was on a new line, it wasn't. It wasn't a line wrap issue, these were 
> actually returns that I had hit that just weren't registering. I had one 
> chunk of code which showed what I thought was the problem when R 
> crashed. When I opened up the script again after restarting, the problem 
> disappeared, so somehow the returns started to be seen.
> 

If you can reproduce this in the future, it might be worth trying to use 
cut and paste to save a record of the offending text, and sending it to 
the Mac GUI maintainers.  I would guess there's some special code that 
is shown by the editor as a newline but seen by the parser as just 
another character.

Duncan Murdoch



More information about the R-help mailing list