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
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
..@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'
, 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('
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
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.,
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
7 matches
Mail list logo