On Tue, 16 Dec 2008 16:25:07 +0100, Mark Heckmann wrote:
Hi R-users,
I want to apply a function to each column of a data frame that is
numeric.
colwise(), numcolwise() and catcolwise() in plyr package turn a function that
operates on vectors into one that operates on columns of data fra
Bert Gunter
Genentech
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Henrique Dallazuanna
Sent: Tuesday, December 16, 2008 9:32 AM
To: Mark Heckmann
Cc: r-help@r-project.org
Subject: Re: [R] Check if data frame column is numeric
from ?apply:
" 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'."
if any of the columns in your dataframe is not numeric, apply will try
to coerce all of them to the least
Try:
sapply(df, is.numeric)
On Tue, Dec 16, 2008 at 1:25 PM, Mark Heckmann wrote:
> Hi R-users,
>
> I want to apply a function to each column of a data frame that is numeric.
> Thus I tried to check it for each column first:
>
> > apply(df, 2, function(x) is.numeric(x))
>
> A60 A64
Hi R-users,
I want to apply a function to each column of a data frame that is numeric.
Thus I tried to check it for each column first:
> apply(df, 2, function(x) is.numeric(x))
A60 A64 A66a A67 A71 A75a A80
A85 A91 A95 A96 A97
5 matches
Mail list logo