Trying to generate a graph of a time series

Asked

Viewed 183 times

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 he plots a graph "periodic".

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

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().

1

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

Follow a code I made in java following a loop

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, the foreach adds the categories and percentage according to an array I did in the backend. below the repeating structure

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

If you need a reference code on the back, you can tell me. Even if you are not using java you can implement this with some language changes

Browser other questions tagged

You are not signed in. Login or sign up in order to post.