Re: [R] Applyiing mode() or class() to each column of a data.frame XXXX

2011-12-30 Thread Justin Haynes
there is also colwise in the plyr package. library(plyr) colwise(class)(data6) v13 v14 v15 f4 v16 1 integer numeric character factor logical Justin On Thu, Dec 29, 2011 at 4:47 PM, Jean V Adams jvad...@usgs.gov wrote: Dan Abner wrote on 12/29/2011 06:13:11 PM:

Re: [R] Applyiing mode() or class() to each column of a data.frame XXXX

2011-12-30 Thread Hadley Wickham
But be careful because class is a character vector (not necessarily a character vector of length 1) On Fri, Dec 30, 2011 at 10:21 AM, Justin Haynes jto...@gmail.com wrote: there is also colwise in the plyr package. library(plyr) colwise(class)(data6)      v13     v14       v15     f4     v16

[R] Applyiing mode() or class() to each column of a data.frame XXXX

2011-12-29 Thread Dan Abner
Hi everyone, I am attempting to use the apply() function to obtain the mode and class of each column in a data frame, however, I am encountering unexpected results. I have the following example data: v13-1:6 v14-c(1,2,3,3,NA,1) v15-c(Good,Bad,NA,Good,Bad,Bad) f4-factor(rep(c(Blue,Red,Green),2))

Re: [R] Applyiing mode() or class() to each column of a data.frame XXXX

2011-12-29 Thread Mark Leeds
Hi Dan: The reason that happens is because apply expects a matrix as input so, since you sent in a dataframe ( which is really a list with each component the same length ), apply converts the input dataframe to a matrix but, when doing this, it needs to make conversions because a matrix needs to

Re: [R] Applyiing mode() or class() to each column of a data.frame XXXX

2011-12-29 Thread Jean V Adams
Dan Abner wrote on 12/29/2011 06:13:11 PM: Hi everyone, I am attempting to use the apply() function to obtain the mode and class of each column in a data frame, however, I am encountering unexpected results. I have the following example data: v13-1:6 v14-c(1,2,3,3,NA,1)