why does "apply" cause the minimum of dates to become character?
17:33 29 Jan 2026

Consider a vector of date objects, R will calculate the minimum and the result remains of type Date,

class(min(c(as.Date('2000-01-01'), as.Date('2100-01-01'))))

OTOH if the dates are arranged in a matrix or data frame and I iterate over each row with apply the result becomes character. Further, how can I perform a similar vectorized operation keeping the desired class for the result?

df <- data.frame(
  y = as.Date('2000-01-01'),
  z = as.Date('2100-01-01')
)

val1 <- apply(df, 1, min)

class(val1)
r