I would like to apply my custom function to each df in mydfs. I'd like to mutate column timestamp to be strtime_to_dt(timestamp) Tried:
mydfs <- lapply(mydfs, function(x) mutate(x, timestamp = strtime_to_dt(x$timestamp)))
Error: Problem with `mutate()` input `timestamp`.
x Input `timestamp` can't be recycled to size 132.
ℹ Input `timestamp` is `strtime_to_dt(x$timestamp)`.
ℹ Input `timestamp` must be size 132 or 1, not 0.
Then tried:
mydfs <- mydfs %>% map(~mutate(., timestamp = strtime_to_dt(.$timestamp)))
Error: Problem with `mutate()` input `timestamp`.
x Input `timestamp` can't be recycled to size 132.
ℹ Input `timestamp` is `strtime_to_dt(.$timestamp)`.
ℹ Input `timestamp` must be size 132 or 1, not 0.
How can I apply my function strtime_to_dt to each dataframe in mydfs?
(I avoid naming objects after built-ins, so dat = your df. In some operations, the namespace gods treat a data frame named df as a closure because it thinks it is the function named df. Same with data.