r - How do I rename the columns in a list of multi- series zoo objects? -


my r learning curve has got best of me today. so.. have list of multi series zoo objects. i'm trying rename columns in each same values. i'm attempting in last line... , runs without error... names aren't changed. ideas great.

require("zoo")  monthly data of stocks. symbs = c('aapl', 'hov', 'nvda')  importdata <- lapply(symbs, function(symb) get.hist.quote(instrument= symb,        start = "2000-01-01", end = "2013-07-15", quote="adjclose", provider = "yahoo",        origin="1970-01-01", compression = "m", retclass="zoo")) names(importdata) <- symbs  #calculate monthly pct chgs of stocks. monthlypctchgs = lapply(importdata, function(x) diff(x, lag = 1) / lag(x, k = -1)) names(monthlypctchgs) <- symbs  #merge pct chgs , monthly closing prices pricingandperfsmerged = mapply(merge, importdata, lag(monthlypctchgs, k = -1),        simplify = false)  #rename columns in each zoo. lapply(pricingandperfsmerged, function(x) colnames(x) = c('adjclose', 'monthlyperf')) 

you're renaming columns of copy. place use loop instead:

for (i in seq_along(pricingandperfsmerged)) {   colnames(pricingandperfsmerged[[i]]) = c('adjclose', 'monthlyperf') } 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -