4
I imported an Excel database to R and I need to turn it into time series to be able to analyze it. However, when I am going to make the transformation to time series R changes the original values to totally different ones. Below are the steps I used
to import the data:
variavel=read.table("dados.csv", header=T, sep=";", dec=",")
after importing the data, the values appeared correctly in the assigned variable, being values of type 5.547,18...
to transform the data into time series:
library(tseries)# carregando o pacote séries temporais
ts.variavel=ts(variavel, start=c(2000,1), frequency=12) # fazendo a transformação
After the above transformation, when I go to check the data they appear totally changed, for example, the value of 5.547,18 turned 15, the value 5.344,47 turned 7, the value 5.053,42 turned 2 and so on... Strange, isn’t it?! What am I doing wrong?
Daniel’s answer seems plausible but, if it doesn’t solve your problem, could you post an example of your data? For example:
dput(head(variavel))
.– Molx
Thanks for helping, I was able to solve the problem as Daniel answered.
– LongBoarder
This is also worth taking a look at: http://answall.com/questions/9284/erro-ao-converter-n%C3%Bameros-how-convert-factors-to-n%C3%Bameros
– Carlos Cinelli