[R] Deleting rows and store the deleted rows in new data frame
Bansal, Vikas
vikas.bansal at kcl.ac.uk
Sun Jul 24 23:32:49 CEST 2011
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 0 5 ,,,.,
10 135349468 t T 2 0 0 5 ,,c.,
10 135349469 g G 7 0 0 5 ,,a.,
10 135349470 c C 8 0 0 5 ,,,.,
10 135349471 a A 10 0 0 5 ,,,.,
10 135349472 g G 7 0 0 6 aa,.,,
10 135349473 g G 7 0 0 6 ,,c.,,
10 135349474 g G 4 0 0 6 ,,,.,,
10 135349475 a A 8 0 0 6 ,,,.,,
10 135349476 t T 1 0 0 6 g,,.,,
10 135349477 a A 7 0 0 6 ,,,.,,
10 135349478 a A 11 0 0 6 ,,,.,,
I want to delete those rows which contains only . and , in column 9.
and i want to store those rows in new data frame sf.
so my output should be-
df
10 135349468 t T 2 0 0 5 ,,c.,
10 135349469 g G 7 0 0 5 ,,a.,
10 135349472 g G 7 0 0 6 aa,.,,
10 135349473 g G 7 0 0 6 ,,c.,,
10 135349476 t T 1 0 0 6 g,,.,,
sf
10 135349467 g G 4 0 0 5 ,,,.,
10 135349470 c C 8 0 0 5 ,,,.,
10 135349471 a A 10 0 0 5 ,,,.,
10 135349474 g G 4 0 0 6 ,,,.,,
10 135349475 a A 8 0 0 6 ,,,.,,
10 135349477 a A 7 0 0 6 ,,,.,,
10 135349478 a A 11 0 0 6 ,,,.,,
Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London
More information about the R-help
mailing list