Re: [R] Another quantmod question

2011-05-08 Thread Russ Abbott
erica/Chicago > xts Attributes: > NULL > > > str(m) > int [1:1000, 1] 1 2 3 4 5 6 7 8 9 10 ... > > > system.time(x[,1]) # get the first column >user system elapsed > 0.017 0.000 0.017 > > system.time(m[,1]) # ditto >user system

Re: [R] Another quantmod question

2011-05-08 Thread Russ Abbott
simple > workaround would cost everyone using in the other 99.999% of cases to pay a > recurring cost that isn't tolerable. > > If this is frustrating to you you should stop using the class. > > Jeff > > Jeffrey Ryan|Founder| > jeffrey.r...@lemnica.com > &

Re: [R] Another quantmod question

2011-05-08 Thread Russ Abbott
I understand Josh's example: mat <- matrix(1:10, dimnames = list(NULL, "A")) cbind(X = 11:20, Y = mat + 1) cbind(X = 11:20, Y = mat[, "A"] + 1) In the line, cbind(X = 11:20, Y = mat + 1), it would be nice if an error or warning message were issued to the effect that the "Y = " part is ignored or

[R] Another quantmod question

2011-05-08 Thread Russ Abbott
I'm having troubles with the names of columns. quantmod deal with stock quotes. I've created an array of the first 5 closing prices from Jan 2007. (Is there a problem that the name is the same as the variable name? There shouldn't be.) > close close 2007-01-03 1416.60 2007-01-04

[R] Convenience-at-the-expense-of-clarity (was: quantmod's addTA plotting functions)

2011-05-06 Thread Russ Abbott
7;t know quantmod very well, but even a > cursory look at the pdf file shows that the docs are quite > good. > > As Jeff points out, good documentation is not easy. More good > examples are always better, but that's mighty time-consuming. > > Peter Ehlers > > > On 2

Re: [R] quantmod's addTA plotting functions

2011-05-05 Thread Russ Abbott
to wrap plot calls in another plot call. On Thu, May 5, 2011 at 3:39 AM, P Ehlers wrote: > On 2011-05-05 0:47, Russ Abbott wrote: > >> Hi, >> >> I'm having trouble with quantmod's addTA plotting functions. They seem to >> work fine when run from the com

[R] quantmod's addTA plotting functions

2011-05-04 Thread Russ Abbott
Hi, I'm having trouble with quantmod's addTA plotting functions. They seem to work fine when run from the command line. But when run inside a function, only the last one run is visible. Here's an example. test.addTA <- function(from = "2010-06-01") { getSymbols("^GSPC", from = from) GS

Re: [R] Still confused about classes

2011-04-29 Thread Russ Abbott
ession, > methods("Date") lists 36 "possible methods" but after library(zoo) I > get two more ( "as.yearmon.Date" and "as.yearqtr.Date"). > > Regards, > Kenn > > > On Fri, Apr 29, 2011 at 9:05 AM, Russ Abbott > wrote: > > Hi

[R] Still confused about classes

2011-04-28 Thread Russ Abbott
Hi, I'm still confused about how to find out what methods are defined for a given class. For example, I know that > today <- Sys.Date() will produce an object of type Date. But I'm not sure what I can do with Date objects or how I can find out. > ?Date refers me to the Date documentation pag

[R] Help with objects

2011-04-25 Thread Russ Abbott
describe the instance variables in a quantmod object. Thanks. *-- Russ Abbott* *_* *** Professor, Computer Science* * California State University, Los Angeles* * Google voice: 747-*999-5105 * blog: *http://russabbott.blogspot.com/ vita: http://

Re: [R] R and lazy evaluation

2011-04-09 Thread Russ Abbott
[1] 0 1 2 again: 1 1 2 [1] -1 0 1 again: 1 1 1 [1] 3 5 8 *-- Russ Abbott* *_* *** Professor, Computer Science* * California State University, Los Angeles* * Google voice: 747-*999-5105 * blog: *http://russabbott.blogspot.com/ vita: http://s

Re: [R] R and lazy evaluation

2011-04-09 Thread Russ Abbott
rs[n] : only 0's may be mixed with negative subscripts *-- Russ Abbott* *_* *** Professor, Computer Science* * California State University, Los Angeles* * Google voice: 747-*999-5105 * blog: *http://russabbott.blogspot.com/ vita: http://site

Re: [R] R and lazy evaluation

2011-04-09 Thread Russ Abbott
3 5 8 13 21 34 55 89 *-- Russ * On Fri, Apr 8, 2011 at 8:36 PM, Russ Abbott wrote: > Here's how to do it in Haskell. > > First define fibs to be an infinite list. Since Haskell is lazy, the list > isn't actually created until needed. > > The function zipWith takes

Re: [R] R and lazy evaluation

2011-04-08 Thread Russ Abbott
- c(0, 1, (fibs + fibs[-1])) Error: object 'fibs' not found But since this is a recursive definition in a context in which recursion is not expected, an error message is produced. *-- Russ * On Fri, Apr 8, 2011 at 12:51 AM, peter dalgaard wrote: > > On Apr 8, 2011, at 06:08 , R

[R] R and lazy evaluation

2011-04-07 Thread Russ Abbott
Haskell is the prototypical lazy evaluation language. One can compute a Fibonacci sequence by the Haaskell equivalent of the following R code. > fibs <- c(0, 1, rep(0, 8)) > fibs[3:10] <- fibs + fibs[-1] This works as follows. fibs = 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 fibs = 0, 1, 0, 0, 0, 0, 0, 0, 0,

Re: [R] R as a non-functional language

2011-03-19 Thread Russ Abbott
; > The idiom I prefer is > > pH <- structure(c(4.5,7,7.3,8.2,6.3), >names = c('area1','area2','mud','dam','middle')) > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r

[R] R as a non-functional language

2011-03-19 Thread Russ Abbott
I'm reading Torgo (2010) *Data Mining with R*in preparation for a class I'll be teaching next quarter. Here's an example that is very non-functional. > pH <- c(4.5,7,7.3,8.2,6.3) > names(pH) <- c('area1','area2','mud','dam','middle') > pH

Re: [R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
etween these too.) > > So, if you're new to R and don't really need reference variables (most > people don't), rethink how you think of classes and objects in R (= > think functional language). Though, you would learn lots by playing > around with environments and scope

Re: [R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
Wonderful! Thanks. I think I've got it. You can even put this <- environment() at the top as long as this is returned at the end. I gather that the environment keeps accumulating elements even though it is assigned to 'this' at the beginning. I had thought that $ worked only on lists,

Re: [R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
; -- Bert > > On Sat, Mar 19, 2011 at 5:51 PM, Janko Thyson > wrote: > > You might want to check out Reference Classes (?SetRefClass). The object > > itself is stored in '.self' and can be referenced that way. > > > > HTH, > > Janko > > >

Re: [R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
;) +total <<- total - amount + cat(amount,"withdrawn. Your balance is", *this,balance()*, "\n\n") But that doesn't work. Is it possible to do this? Thanks. *-- Russ Abbott* *_* *** Professor, Comput

[R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
Is it possible to refer to an object from within a method, as in *this *in Java? I can't find anything about this in the documentation. Sorry if I missed it. Thanks. *-- Russ Abbott* *_* *** Professor, Computer Science* * California