Re: [R] Remove non-numerical columns from data frame

2008-07-26 Thread Henrik Bengtsson
On Sat, Jul 26, 2008 at 9:35 AM, Peter Dalgaard <[EMAIL PROTECTED]> wrote: > Henrique Dallazuanna wrote: >> >> Try this: >> >> x <- data.frame(A=c(10,20), B = c("a", "b"), C = c(20,30)) >> x[sapply(x, is.numeric)] >> >> > > Yes, and read ?Extract to clear up the confusion between data$vol and > dat

Re: [R] Remove non-numerical columns from data frame

2008-07-26 Thread Peter Dalgaard
Henrique Dallazuanna wrote: Try this: x <- data.frame(A=c(10,20), B = c("a", "b"), C = c(20,30)) x[sapply(x, is.numeric)] Yes, and read ?Extract to clear up the confusion between data$vol and data[257] and data[[257]] (Section on "Recursive (list-like) objects:"). Also, ?Extract.data.frame

Re: [R] Remove non-numerical columns from data frame

2008-07-26 Thread Henrique Dallazuanna
Try this: x <- data.frame(A=c(10,20), B = c("a", "b"), C = c(20,30)) x[sapply(x, is.numeric)] On Sat, Jul 26, 2008 at 11:19 AM, Markus Mühlbacher <[EMAIL PROTECTED]> wrote: > Hello, > > My question sounds simple, but as I am desperatly searchin for a solution I am > asking you all. :) > > I try t

[R] Remove non-numerical columns from data frame

2008-07-26 Thread Markus Mühlbacher
Hello, My question sounds simple, but as I am desperatly searchin for a solution I am asking you all. :) I try to filter out all non-numeric columns of a data frame using a for loop to go through all columns. My if clause looks like this: for(j in 1:length(data)) { ...