Re: [R] Check if data frame column is numeric

2008-12-17 Thread Vitalie Spinu
On Tue, 16 Dec 2008 16:25:07 +0100, Mark Heckmann mark.heckm...@gmx.de 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

[R] Check if data frame column is numeric

2008-12-16 Thread Mark Heckmann
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

Re: [R] Check if data frame column is numeric

2008-12-16 Thread Henrique Dallazuanna
Try: sapply(df, is.numeric) On Tue, Dec 16, 2008 at 1:25 PM, Mark Heckmann mark.heckm...@gmx.de 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

Re: [R] Check if data frame column is numeric

2008-12-16 Thread Wacek Kusnierczyk
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

Re: [R] Check if data frame column is numeric

2008-12-16 Thread Bert Gunter
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 Try