[R] Summary to data frame in R!!

peter dalgaard pdalgd at gmail.com
Wed May 21 11:26:33 CEST 2014


On 07 May 2014, at 17:55 , Marc Schwartz <marc_schwartz at me.com> wrote:

>> as.data.frame(sapply(mtcars[, c("mpg", "disp")], summary))

I'd use lapply() rather than sapply() here. That goes directly from a list to a data frame, avoiding the detour via a matrix. 

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list