[R] extract common rows from a dataframe

Bert Gunter gunter.berton at gene.com
Tue Jun 11 22:44:13 CEST 2013


1. What does "common" mean?
(noting that 39.35 != 39.33 )

2. But:
?"["
## or easier, but less flexible
?subset


Also, spend some time with "An Introduction to R."

Unless I misunderstand, this is very basic, and you need to first put
in some time to learn R's basic procedures instead of posting here.

Hint:

> x <- data.frame(a = sample(1:3,10,rep=TRUE), b = sample(letters[1:10],10))
> x[x$a == 3,]

Cheers,
Bert

On Tue, Jun 11, 2013 at 8:45 AM, Ellie Papazisi <elliepapazisi at gmail.com> wrote:
> Hello, I'm trying to extract the common rows from a data frame, which is
> something like this :
>
>
> *   DEPTH SALINITY DEPTH SALINITY*
> *18    87    39.06    94    39.06*
> *19   173    39.05   141       NA*
> *20   260    39.00   188    39.07*
> *21   312    38.97   207    39.03*
> *22     1    39.36     1    39.35*
> *23    10    39.36    10    39.33*
> *24    20    39.36    20    39.33*
> *25    30    39.35    30    39.33*
> *
> *
> i want to extract the rows with the same depth.
> i cannot do something like *data.frame[22:25,]* because i have lots of rows
>
> any help?
> thank you
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list