With R issue using as.date to format a date column in a list with uniform column names between elements

Spencer Source

I have a list of 23 elements with the column headers being: Date, sessions, Station for each element.

I want to format the date from, as an example, 20170202 to 2017-02-02 but apply this change to all elements and re-write the old date format.

The below code is what I have so far but the issue is instead of appending the existing columns it just creates a new element in the list with the new date format.

ga.data.list$Date <- lapply(ga.data.list$Date, function(x) as.Date(x, '%Y%m%d'))

Am I misunderstanding the purpose of lapply? I want to apply a function (as.Date) to transform data in all elements of my list. Thoughts?



comments powered by Disqus