Re: [R] source() does not include added code

2016-08-31 Thread Doug Edmunds

Thank you.  That explains it (auto-printing is not done).

On 8/31/2016 8:35 AM, Joshua Ulrich wrote:

I have quantstrat installed and it works fine for me.  If you're
asking why the output of t(tradeStats('macross')) isn't being printed,
that's because of what's described in the first paragraph in the
*Details* section of help("source"):

 Note that running code via ‘source’ differs in a few respects from
 entering it at the R command line.  Since expressions are not
 executed at the top level, auto-printing is not done.  So you will
 need to include explicit ‘print’ calls for things you want to be
 printed (and remember that this includes plotting by ‘lattice’,
 FAQ Q7.22).

So you need:

print(t(tradeStats('macross')))

if you want the output printed to the console.



__
R-help@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.

Re: [R] source() does not include added code

2016-08-31 Thread Doug Edmunds

1.  File is (was) saved.
2.  The added code is
 t(tradeStats("macross"))
with 2 )'s.

I'd appreciate if someone with QuantStrat installed, to try this
and see if they get a different result.  My R and RStudio and
QuantStrat libraries are all current.


I get the chart and this much output.

> source('~/CodingData/RCode/Quantstrat1/maCross.R')
[1] "2001-06-27 00:00:00 AAPL 100 @ 1.526312"
[1] "2001-09-07 00:00:00 AAPL -100 @ 1.13002"
[1] "2002-01-07 00:00:00 AAPL 100 @ 1.497538"
[1] "2002-07-10 00:00:00 AAPL -100 @ 1.132636"
[1] "2003-05-16 00:00:00 AAPL 100 @ 1.22942"
[1] "2006-06-22 00:00:00 AAPL -100 @ 7.792429"
[1] "2006-09-26 00:00:00 AAPL 100 @ 10.150561"
[1] "2008-03-07 00:00:00 AAPL -100 @ 15.988996"
[1] "2008-05-19 00:00:00 AAPL 100 @ 24.012922"
[1] "2008-09-24 00:00:00 AAPL -100 @ 16.833895"
[1] "2009-05-14 00:00:00 AAPL 100 @ 16.080549"
[1] "2012-12-11 00:00:00 AAPL -100 @ 71.436852"
[1] "2013-09-11 00:00:00 AAPL 100 @ 62.897826"
[1] "2015-08-31 00:00:00 AAPL -100 @ 110.399553"
Time difference of 0.3014359 secs
[1] "trade blotter portfolio update:"
Time difference of 0.1732061 secs
>

__
R-help@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.


[R] source() does not include added code

2016-08-31 Thread Doug Edmunds

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

__
R-help@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.


[R] removing lines from text file

2012-08-23 Thread Doug Edmunds
I downloaded a text file which has several lines of text before the 
header line of the data, similar to this:


---start---
Corn December 2012 (CZ2012)
Source:  Wikiposit Open Data via wikiposit.org 
(http://wikiposit.org/uid?FUTURE.CZ2012)
Update: 
http://wikiposit.org/w?action=dldltypes=comma%20separatedsp=dailyuid=FUTURE.CZ2012


Date,Open,High,Low,Settle,Volume,OpenInt,
08-Jun-2009,0,469.5,469.5,469.5,0,0,
09-Jun-2009,0,476.75,469.5,476.75,0,0,
...

After I download the file using R, how do I remove the lines of text
that appear before the header line (Date, Open, ...)?

__
R-help@r-project.org mailing list
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.