I have a df that comes from an api with a Trimestre (Código) column in string format:
pib$`Trimestre (Código)` <- c(199101,199102,199103,199104,199201,199202,...)
but i need to mutate this column into date format. I have tried the folowing:
>
> pib %>%
> mutate(date = parse_date(`Trimestre (Código)`, format='%Y%q')) %>%
> select('Trimestre (Código)', "Setores e subsetores", Valor) %>%
> pivot_wider(names_from = "Setores e subsetores",
> values_from = Valor)
but I just receive the error ‘unsupported format %q’. How to do it?
>Solution :
library(lubridate)
library(dplyr)
pib <- data.frame(Trimestre = c(199101,199102,199103,199104,199201,199202))
pib %>%
mutate(date = yq(Trimestre))
Edit: Just saw you got the answer in the comments