Re: [R] using apply to a data frame

2016-04-07 Thread David Winsemius
> On Apr 7, 2016, at 1:25 PM, John Sorkin wrote: > > > ‪‪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. As Bert pointed out yo

Re: [R] using apply to a data frame

2016-04-07 Thread Peter Langfelder
Use lapply or sapply. A data frame is also a list with each component representing one column; lapply/sapply will apply the function to each column. Peter On Thu, Apr 7, 2016 at 1:25 PM, John Sorkin wrote: > > ‪‪I would like to apply a function, fract, to the columns of a > dataframe. I tried th

Re: [R] using apply to a data frame

2016-04-07 Thread Bert Gunter
Inline. -- Bert Bert Gunter On Thu, Apr 7, 2016 at 1:25 PM, John Sorkin wrote: > > ‪‪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 > fr

Re: [R] using apply to a data frame

2016-04-07 Thread Luisfo Chiroque via R-help
Dear John, Try using sapply(data5NonEventEpochs, fract) HTH Best, Luisfo Chiroque PhD Student IMDEA Networks Institute http://fourier.networks.imdea.org/people/~luis_nunez/ > El 7 abr 2016, a las 23:25, John Sorkin > escribió: >

[R] using apply to a data frame

2016-04-07 Thread John Sorkin
‪‪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 data5NonEventsE