# Plot Evolution of portfolio weights over time in R [closed]

Is there any function for plotting the evolution of portfolio weights over time in r?. I have a matrix of portfolio weights from an equal weighting strategy at rebalancing times and want to plot weights of the stocks over time on a single plot.

for example:you want to backtest equal weight strategy where you allocate weights equally at each rebalancing dates for each stock. I have a matrix of weights:

             A       B            C       D              E           F


2001-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2002-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2003-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2004-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2005-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2006-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2007-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2008-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2009-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2010-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

2011-12-01 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806 0.03225806

I want to plot the stocks(A,B,..) on a single plot where the y axis will be the allocatons and x axis the time ie plotting a transition map for weights over time using R

Regards

• Could you please provide more information like e.g. code, an example matrix with the weights etc.? – vonjd Jun 30 '14 at 9:13
• I think this is off-topic because in short you ask how to plot multvariate time series - right? Look at the xts package cran.r-project.org/web/packages/xts/index.html and get to know time formats in R. – Ric Jun 30 '14 at 10:29
• This is a simple programming question. – Ric Jun 30 '14 at 10:30
• Although the question has been closed you can still upvote my answer and accept it if it was helpful - Thank you :-) – vonjd Jun 30 '14 at 14:03
• Thank you, I was able to figure out what I really needed, I wanted stacked Area Graph to plot the weights over time. I used the ggplot after changing my time series object to long format.@vonjd – user3481555 Jun 30 '14 at 14:31

You can use the zoo package:
library(zoo)