Skip to content
Prev 349917 / 398513 Next

operations on columns when data frames are in a list

If you write a function that takes a data frame as an argument and returns
a data frame, you can use lapply to carry out the tasks that you want.  For
example, if your list of data frames is called mydat ...

mon2date <- function(df) {
  if ("Month" %in% names(df)) {
    df$Month<- as.POSIXct(df$Month, format="%Y/%m/%d")
  }
  return(df)
}

mydat2 <- lapply(mydat, mon2date)

Jean
On Sun, Apr 12, 2015 at 5:30 PM, Steve E. <searl at vt.edu> wrote: