[R] using apply to a data frame

Luisfo Chiroque luisfo89 at yahoo.es
Thu Apr 7 22:34:38 CEST 2016

Dear John,

Try using
	sapply(data5NonEventEpochs, fract)


Luisfo Chiroque
PhD Student
IMDEA Networks Institute
http://fourier.networks.imdea.org/people/~luis_nunez/ <http://fourier.networks.imdea.org/people/~luis_nunez/>
> El 7 abr 2016, a las 23:25, John Sorkin <JSorkin at grecc.umaryland.edu> escribió:
> ‪‪I would like to apply a function, fract, to the columns of a
> dataframe. I tried the following 
> apply(data5NonEventEpochs,2,fract)
> but, no surprise it did not work as apply works on matrices not data
> frames. How can I apply a fuction to the columns of a data frame? (I
> can't covert data5NonEventsEpochs to a matrix as it contains character
> data).
> Thank you,
> John
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
> Confidentiality Statement:
> This email message, including any attachments, is for ...{{dropped:16}}

More information about the R-help mailing list