Most common way to add derived columns to an XTS object?
It seems the missing piece in the puzzle was to define the column first with
SD$STDDEV = rep(0, NROW(SD))
for (i in 1:NROW(SD)) {
SD[i, "STDDEV"] = SD[i, "StdDev Log Change"] * Cl(AAPL)[i];
}
then I can expect to assign values to it.
On Mar 10, 2010, at 8:12 AM, Joshua Ulrich wrote:
You already asked and received an answer for this question. I also answered you when you asked me this question off-list. Please don't post duplicate questions, especially when they were answered only days ago! As Jeff Ryan said, use merge.xts. See ?merge.xts. x <- .xts(1:10,1:10) y <- merge(x,d=diff(x)) As I said, use "$<-". See ?"$". y$r <- rnorm(NROW(y)) Do some work. No one is going to spoon feed you. -- Joshua Ulrich FOSS Trading: www.fosstrading.com On Wed, Mar 10, 2010 at 7:52 AM, Robert Nicholson <robert.nicholson at gmail.com> wrote:
So you have data in your XTS object and all I'm trying to do is add columns (attributes) that are derived values. does anybody have an example of this? I'm trying to perform a simply transformation on an existing attribute in my XTS object and store the value as a new attribute.
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.