search for: meddat

Displaying 1 result from an estimated 1 matches for "meddat".

Did you mean: meddate
2005 Feb 24
2
Row median of Date class variables in a data frame
.... Thank you, Stephen Weigand ### Test data date1 <- c(1000, 2000, 3000,4000) date2 <- date1 + 100 date3 <- date2 + 100 class(date1) <- class(date2) <- class(date3) <- "Date" test <- data.frame(date1, date2, date3) print(test) ### create a function for apply() medDate <- function(x){ obj <- unclass(unlist(x)) med <- median(obj, na.rm = TRUE) med class(med) <- "Date" med } medDate(test$date1) # works medDate(test[1,]) # works apply(test, 1, medDate) # gives error: 'need numeric data' apply(test, 2, medDate) # give...