Attempting to generate a graph of a time series

5

That's what I did ..

#Lê a base de dados
ano1<-read.csv("os dados abaixo...",header = TRUE ,sep=";", row.names=1)

#Cria a série temporal
ano<-ts(ano1[,1],start=c(2009,1), end=c(2010,12),freq=12)

#plota a série
plot(ano,ylab='indice', xlab='ano',main='distribuiçao dos casos')

These are the data:

​##       Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
## 2009  1.6  1.0  0.2  0.0 -0.2  0.1  0.9  1.4  0.8 -0.4 -0.8  0.1
## 2010  1.8  1.2  0.3 -0.1 -0.2 -0.3  1.5  1.9  1.2  0.1 -0.6 -0.5

But it plots a "periodic" chart.

Ps .: It's several years, but I wanted to learn in this 'simple' to apply in the other.

    
asked by anonymous 07.06.2016 / 20:38

2 answers

2

My suggestion would be for you to transpose the data using the t () command, and then plot using the matplot () or ts.plot () command.

    
23.06.2016 / 19:45
1

You can make use of a for to create the list of years, if the data is in an array, it will be populated according to the index

graphDonut = Morris.Donut({
                element: 'hero-donut', // elemento chave de referencia
                data: [// dados do grafico
        <c:forEach items="${valorList}" var="catP">

                    {label: '${catP.categoria}', value: '${catP.porcentagem}'},
        </c:forEach>
                ],
                colors: ['#8bc34a', '#ffc107', '#34495e', '#03a9f4', '#9c27b0', '#90a4ae'], //cores do grafico

                formatter: function (y) {

                    return y;
                }
                , //formatação dos números a exibir
                resize: true // redimensionavel true
            });

In it, we have a graphDonut, where we have categories and percentage, forEach makes the add of the categories and percentage according to an array that I made in the backend. below the repeating structure

{label: '${catP.categoria}', value: '${catP.porcentagem}'},

If you need some reference code in back, you can speak to and. Even if you are not using java you can implement this with some changes according to the language

    
07.06.2016 / 20:50