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? --DAE
On Wed, Aug 31, 2016 at 10:05 AM, Doug Edmunds <dougedmunds at gmail.com> 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? >My guess is that you forgot to save the file after you made your change. That never happens to me. :P> --DAE > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com R/Finance 2016 | www.rinfinance.com
> On Aug 31, 2016, at 8:05 AM, Doug Edmunds <dougedmunds at gmail.com> 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.Have you read the help page? On my machine the default for verbose appears to be getOption("verbose") [1] FALSE> > Why not? > > --DAE > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius Alameda, CA, USA
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
If it doesn't do ANYTHING, you may have failed to save the file. Unless that file contains a function, in which case it isn't supposed to do anything except load the function into your global environment. But it should have thrown an error in that case, as Duncan said. On Wed, Aug 31, 2016 at 11:11 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:> 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 > >