It all depends on what you are doing. Take a look at 'apply'; it says: If X is not an array but has a dimension attribute, apply attempts to coerce it to an array via as.matrix if it is two-dimensional (e.g., data frames) or via as.array.
Now take a look at what happens when you convert your dataframe to a matrix: > x <- as.matrix(mydf) > str(x) chr [1:2, 1:10] "2008-01-08 23:29:25" "2008-01-08 23:29:25" "2008-01-08 23:29:25" ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr [1:10] "X1" "X2" "X3" "X4" ... > It is a character matrix. On Jan 8, 2008 12:28 PM, Thomas Pujol <[EMAIL PROTECTED]> wrote: > How do I retain "POSIXct" formatting when using apply, with FUN=max? > > #example: > mydata <- rep(Sys.time(), 10) > mydf <- data.frame(matrix(data=mydata, nrow=2, ncol=length(mydata) ) ) > for(i in seq(mydf))class(mydf[[i]]) <- class(mydata) > str(mydf) > maxdates <- apply(mydf,2,max,na.rm=T) > str(maxdates) > > #Why is the formattign now "chr", and not "POSIXct"? > #Is there a good way to retin "POSIXct" formatting? > > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.