I have a csv file which contains two columns, time and value. The format of the time column like this "yyyy-mm". For example: '2012-10'. I need to read the file from a shiny app and need to convert it in a time series. But I find difficulties converting the time format into time series . Can anyone please help me regarding this issue?

Thanks in advance.

*I am very new in this shiny sector.

Here is the short snippet of my csv file:
date

Does the value in the Value column represent the day, i.e. does combining the Date and Value column row-wise represent a date?

Not Actually. The file contains the monthly number of customers of a company. So the Value column represents the number of customers here.

Here is one solution.

DF = data.frame(Date=c("2012-02","2012-03","2012-04"),
                Value=c(18,25,31))
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
DF$Date <- ym(DF$Date)
DF
#>         Date Value
#> 1 2012-02-01    18
#> 2 2012-03-01    25
#> 3 2012-04-01    31

Created on 2022-07-21 by the reprex package (v2.0.1)

1 Like

Thank you so much @FJCC for the reply. Can you help me with an another issue ? I have a file with a irregular date format . I am giving a picture with the date format. How can I convert this to a time series?

Thank in advance again.
date

The lubridate package has many convenient functions for changing text to dates. It looks like your dates are in a month/day/year format, so you can use the mdy() function in the same way that I used the ym() function above.