[Rd] Parser Bug Somewhere.... (PR#460)

Thomas Lumley thomas@biostat.washington.edu
Mon, 28 Feb 2000 02:27:19 +0000 (GMT)


On Mon, 28 Feb 2000 john-cavanaugh@cableone.net wrote:

> Full_Name: John P Cavanaugh
> Version: .99
> OS: linux
> Submission from: (NULL) (24.116.10.99)
> 
> 
> dataset$ema12 <- EMA (dataset$Close,12)
> dataset$ema26 <- EMA (dataset$Close,26)
> dataset$MACD_fast <- dataset$ema26 - dataset$ema12
> dataset$MACD_slow <- EMA(dataset$MACD_fast,9)
> 
> dataset$MACD_hist <- dataset$MACD_fast - dataset$MACD_slow  # This line doesnt
> work!!!
> 
> 
> But... if I does work if I do the following
> 
> dataset$MACDfast <- dataset$ema26 - dataset$ema12
> dataset$MACDslow <- EMA(dataset$MACDfast,9)
> dataset$MACDhist <- dataset$MACDfast - dataset$MACDslow
> 
> Something seems wrong if you have an underscore in the dataname.  I think
> this is a valid name and shouldnt need to be escaped inside of "". 

No, it's not a valid name. The underscore is a synonym for the assignment
operator <-, and so needs to be quoted if you use it. 

If you think this is horrible you're quite right, but the S language
allows _ for <- and many people are used to it.

The commonest S usage is MACD.fast, though some people use capital letters
for embedded words -- MACDFast. Both are used in the base R package:
as.vector(), getOption().


Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._