Re: [R] Deleting rows and store the deleted rows in new data frame

2011-07-24 Thread Jorge Ivan Velez
t; From: Jeff Newmiller [] > Sent: Monday, July 25, 2011 1:02 AM > To: Bansal, Vikas; Phil Spector > Cc: r-help@r-project.org > Subject: Re: [R] Deleting rows and store the deleted rows in new data frame > > You can, but you would have to convert them to character first. It would b

Re: [R] Deleting rows and store the deleted rows in new data frame

2011-07-24 Thread Bansal, Vikas
atics Kings College London From: Phil Spector [spec...@stat.berkeley.edu] Sent: Monday, July 25, 2011 12:29 AM To: Bansal, Vikas Cc: r-help@r-project.org Subject: Re: [R] Deleting rows and store the deleted rows in new data frame There's no need to use sapply or loops with gre p

Re: [R] Deleting rows and store the deleted rows in new data frame

2011-07-24 Thread Jeff Newmiller
..@stat.berkeley.edu] Sent: Monday, July 25, 2011 12:29 AM To: Bansal, Vikas Cc: r-help@r-project.org Subject: Re: [R] Deleting rows and store the deleted rows in new data frame There's no need to use sapply or loops with grep -- it's already vectorized. So you can find the rows you'

Re: [R] Deleting rows and store the deleted rows in new data frame

2011-07-24 Thread Bansal, Vikas
, 2011 12:29 AM To: Bansal, Vikas Cc: r-help@r-project.org Subject: Re: [R] Deleting rows and store the deleted rows in new data frame There's no need to use sapply or loops with grep -- it's already vectorized. So you can find the rows you're interested in with > wh = grep('

Re: [R] Deleting rows and store the deleted rows in new data frame

2011-07-24 Thread Phil Spector
There's no need to use sapply or loops with grep -- it's already vectorized. So you can find the rows you're interested in with wh = grep('^[.,]+$',df[,9]) store them with sf = df[wh,] and delete them with df = df[-wh,] - Phil Spector

Re: [R] Deleting rows and store the deleted rows in new data frame

2011-07-24 Thread Steven Kennedy
Hi Vikas, The following works (I'm not very good with sapply, but the for loop is ok if your data set is not huge). > df <- read.table("test.txt",stringsAsFactors=FALSE) > df V1V2 V3 V4 V5 V6 V7 V8 V9 1 10 135349467 g G 4 0 0 5 ,,,., 2 10 135349468 t T 2 0 0 5 ,,c.,

[R] Deleting rows and store the deleted rows in new data frame

2011-07-24 Thread Bansal, Vikas
Dear all, I am using grep but I did not understand the problem as I am doing something wrong.Please help me. I am using this code- sf=data.frame(sapply(df[],function(x) grep('\\.&\\,', df[,9]))) the thing is i have a data frame(df) like this- 10 135349467 g G 4 0