require(reshape2)
dcast(stock.returns, Date ~ Ticker)
The numbers were changed from their original values, but if you originally
created the values Return as.numeric they should stay the same
On Wednesday, March 16, 2011 at 9:37 AM, chris99 wrote:
Hi group,
>
> I am trying to convert the organi
Try this:
xtabs(Return ~ Date + Ticker, stock.returns)
On Wed, Mar 16, 2011 at 11:37 AM, chris99 wrote:
> Hi group,
>
> I am trying to convert the organization of a data frame so I can do some
> correlations between stocks,
>
> I have something like this:
>
> stock.returns <-
> data.frame(rbind(
Here's one way:
ans = reshape(stock.returns,idvar='Date',
+varying=list(names(stock.returns)[-1]),
+direction='long',
+times=names(stock.returns)[-1],
+v.names='Return',timevar='Ticker')
rownames(ans) = NULL
ans
Date Ticke
Hi group,
I am trying to convert the organization of a data frame so I can do some
correlations between stocks,
I have something like this:
stock.returns <-
data.frame(rbind(c("MSFT","20110301",0.05),c("MSFT","20110302",0.01),c("GOOG","20110301",-0.01),c("GOOG","20110302",0.04)))
colnames(stock.
4 matches
Mail list logo