0
I’ve encountered very similar problems, but none of them got where I am. I’m trying to read a CSV file and turn it into Time Series.
download.file('https://drive.google.com/u/3/uc?id=1hAQfAKXmzwWv0ZEcE2j_kiUcXplHLOSTB&export=download',
destfile = 'STP.csv')
STP = read.csv2('STP.csv',header = FALSE,';', col.names = c('Data', 'Indice'), skip = 1)
Here I created the object in Dataframe that generated this spreadsheet (actually the spreadsheet has 336 entries but here are the first 20)
STP$Data=as.Date(STPData, format = '%m/%Y')
When I do this my dataframe looks like this:
If I try without the format it says that the format is not unambiguous.
I spent a few hours searching in Google similar cases and I can’t understand what happens. I’ve used sapply(STP, class)
before and after. Before it says that the date column is of type Character and then, when NA, as date.
Welcome to Stackoverflow! Unfortunately, this question cannot be reproduced by anyone trying to answer it. Instead of sharing the file via Google Drive, take a look at this link (mainly in the use of function
dput
) and see how to ask a reproducible question in R. So, people who wish to help you will be able to do this in the best possible way.– Marcus Nunes
Use
dput
or simulate the data, your question does not exactly depend on your spreadsheet. And remove the references to the readr library, it is not used in the code posted.– Carlos Eduardo Lagosta
The error comes from the date only having month and year, need one day. Try, for example day 1.
paste0("1/", STP$Data)
.– Rui Barradas