The way to get the best answers on r-help (and the method advised in
the Posting Guide) is to offer the audience a specification of the
libraries being used, to create examples that illustrate the sort of
input expected, to offer the code that is being used, and to clearly
specify what output is needed. I only saw one of those aspects in your
posting.
The lack of example input was the feature that held me off from
further efforts, although others may have had their own reasons. You
may think ticker objects are a well defined data type, but they are
not so for me.
(You should also send plain text, again as the Posting Guide specifies.)
--
DW
On Jun 25, 2009, at 11:27 PM, R_help Help wrote:
Thanks David for reading for me. Anyhow, is there better way to do
looping on xts objects than using apply? Thanks again.
adschai
On Thu, Jun 25, 2009 at 12:39 AM, David Winsemius <dwinsem...@comcast.net
> wrote:
On Jun 24, 2009, at 9:26 PM, R_help Help wrote:
Hi,
I do not understand why after I called apply on a function that
returns an
xts (getIdvAdjSeries) it returns a matrix whose columns are just
numeric
value of time series in xts instead of a list of xts objects.
Basically, I called the following:
apply(matrix(tickers,ncol=1),1,FUN=getDivAdjSeries)
getDivAdjSeries <- function(ticker) {
seriesName <- paste(ticker,"Adjusted",sep=".");
command <- parse(text=paste(ticker,"[,'",seriesName,"']",sep=""));
s <- eval(command);
dimnames(s)[[2]] <- ticker;
command <- parse(text=paste(ticker,"@index",sep=""));
s <- xts(s,index=eval(command));
return(s);
}
This doesn't seem to work. Can anyone shed some light please? Thank
you.
That would appear to be the expected behavior after reading the Value
section of the help page for apply.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.