@williaml
this is so frustrating. In the original file, which is a csv, the column header is called: Book.Fiscal.Month.String with the associated dates of 2018-M01. That's it, so I don't understand why the following didn't create a new column called 'year' and store the new values into that column. Any help is greatly appreciated.
COPA_RT$Book.Fiscal.Month.String <- str_remove("2018-M01", "M")
COPA_RT$Year <- as.yearmon(COPA_RT$Book.Fiscal.Month.String)
COPA_RT$Year <- as.Date(COPA_RT$Year)
I even tried your other solution and still no luck in capturing a new column:
COPA_RT %>%
mutate(month = str_remove(Book.Fiscal.Month.String, "M")) %>%
mutate(month = as.yearmon(month)) %>%
mutate(month = as.Date(month))
write.csv(COPA_RT_Rev, file=paste("COPA_RT_Rev",fileTag,format(Sys.time(),"%d-%b-%Y %H_%M"),".csv", sep=""), row.names = FALSE)
It shows in the output that month is a new column with the new dates, but when I open up the file after it's been written to a csv, there's no new 'month' column at the end like it showed in the output.