Skip to content
Back to formatted view

Raw Message

Message-ID: <9f3fccde-da31-881f-b6bf-1987d14dff9b@gmail.com>
Date: 2016-08-31T15:11:27Z
From: Duncan Murdoch
Subject: source() does not include added code
In-Reply-To: <2d5ce5c3-5c16-1f56-fe85-62868614030e@gmail.com>

On 31/08/2016 11:05 AM, Doug Edmunds wrote:
> I am trying to understand why "source" does not process
> all the code in this R file.
>
> 1. I copied maCross.R from the quantstrat/demo directory
> into my project area.
>
> QuantStrat is available at
>    https://r-forge.r-project.org/R/?group_id=316
> install.packages("quantstrat", repos="http://R-Forge.R-project.org")
>
> 2. I added this line at the end of the R file:
>
>      t(tradeStats("macross")
>
> 3. When I enter:
>       source('maCross.R')
>
> at the prompt, it fails to process the added line of code.
>
> Why not?

You're missing a closing parenthesis.  I'd have hoped for an error 
message about that, and I get one with a similar example. Not sure why 
you didn't.

 > source('test.R')
Error in source("test.R") : test.R:4:0: unexpected end of input
2: message("bad"
3:

Duncan Murdoch