[R] Relative subscripting
jeaneid at chass.utoronto.ca
Tue Nov 30 22:51:13 CET 2004
wouldn't it be return[2:NROW(return)]*marketcap[1:(NROW(return)-1)]
(note that return is also a function in R so maybe you should stay away
from calling your variable return. Anyways if you have a data frame you
can add another variable to it but attach an NA to the first element
(since you are lagging variables) i.e.
On Tue, 30 Nov 2004, Tobias Muhlhofer wrote:
> I'm trying to do the following.
> I have monthly a dataset with, among other things, "marketcap", and
> I want to multiply return by the marketcap of the previous month. How do
> I do this?
> In STATA (which I have used frequently in the past) I would simply use
> an expression of the form
> I believe they call this relative subscripting. Is there something like
> this in R?
> On a completely different note, are there books on R? I read the
> "Getting Started" notes, but, while helpful, I would need more than those.
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help