Skip to content
Prev 359896 / 398503 Next

using apply to a data frame

Inline.

-- Bert
Bert Gunter
On Thu, Apr 7, 2016 at 1:25 PM, John Sorkin <JSorkin at grecc.umaryland.edu> wrote:
That is false! From ?apply:

"If X is not an array but an object of a class with a non-null dim
value (such as a data frame), apply attempts to coerce it to an array
via as.matrix if it is two-dimensional (e.g., a data frame) or via
as.array."

Your apply() call would not have worked with a matrix either, as your
syntax was wrong.  Here is a corrected example:
a        b
1.676466 2.817189






 How can I apply a fuction to the columns of a data frame? (I