Graph that consider the columns of a matrix as series

Viewed 103

Hi everybody I am working with a matrix in R. This matrix named Matriz.Colocacion has five columns, each column show info about different years 2009, 2010, 2011, 2012 and 2013. Row names of Matriz.Colocacion have the month for each year. My matrix has the next form (I include dput() version of Matriz.Colocacion in the final part):

                 2009       2010       2011       2012       2013
enero       710004.35 1458624.41 6229245.09 4407422.89 3006568.05
febrero     889398.08  942099.60 5553163.01 4248144.11 2615730.00
marzo      1114883.11 1210951.20 6372919.90 3537103.40 2833299.10
abril      1419242.11 1151423.89 6755054.64 3500595.75 3438797.32
mayo       1585857.22 1598355.10 7119008.27 4049074.18 3224926.48
junio      1010455.56 1370856.78 7585411.87 3279868.96 2794029.57
julio      1292333.35 1420547.36 7402737.51 3420974.23 3003458.16
agosto     1032443.35 2048291.06 7250944.21 2602310.30 2486931.57
septiembre 1133260.11 3043637.60 6227706.73 2225635.25 2515076.46
octubre    1229593.84 3669634.09 5795989.01 2853467.41 2674568.38
noviembre  1074569.64 3641665.16 4015226.43 4178671.47       0.00
diciembre  1370905.58 6780879.37 5391952.87 2831027.32       0.00

My problem got when I try to build the graph. I don't know if it is better to separe my matrix in individual series or if there is anyway to use all matrix to plot my wished graph. I would like to get a graphic like this:enter image description here

Where in x axis are showed row.names(Matriz.Colocacion) and in the legend of the graph are showed the diferent years of the matrix (2009,2010,2011,2012,2013).

I don't have enough knowledge of ggplot and I am having some trouble trying to create this graph. The dput() version of my matrix is the next:

structure(c(710004.35, 889398.08, 1114883.11, 1419242.11, 1585857.22, 
1010455.56, 1292333.35, 1032443.35, 1133260.11, 1229593.84, 1074569.64, 
1370905.58, 1458624.41, 942099.6, 1210951.2, 1151423.89, 1598355.1, 
1370856.78, 1420547.36, 2048291.06, 3043637.6, 3669634.09, 3641665.16, 
6780879.37, 6229245.09, 5553163.01, 6372919.9, 6755054.64, 7119008.27, 
7585411.87, 7402737.51, 7250944.21, 6227706.73, 5795989.01, 4015226.43, 
5391952.87, 4407422.89, 4248144.11, 3537103.4, 3500595.75, 4049074.18, 
3279868.96, 3420974.23, 2602310.3, 2225635.25, 2853467.41, 4178671.47, 
2831027.32, 3006568.05, 2615730, 2833299.1, 3438797.32, 3224926.48, 
2794029.57, 3003458.16, 2486931.57, 2515076.46, 2674568.38, 0, 
0), .Dim = c(12L, 5L), .Dimnames = list(c("enero", "febrero", 
"marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", 
"octubre", "noviembre", "diciembre"), c("2009", "2010", "2011", 
"2012", "2013")))

I wait you can help me. Thanks a lot of.

1 Answers
Related