Re: [R] Remove duplicates from a data frame but with some special requirements

2009-12-17 Thread Gray Calhoun
The easiest thing might be to just sort on the Loaded column: start of example d <- read.table(textConnection("ESR_ref ESR_ref_editLoaded 1.1 1.1 Y 1.1.11.1 NC 1.1.21.1 Y 2.1 2.1 N 2.1.

Re: [R] Remove duplicates from a data frame but with some special requirements

2009-12-17 Thread gcam
Thanks Gray, This helps, I'd completely forgotten about the subset command. However, it doesn't quite get me where I need. Perhaps an example will help. I will simplify my dataframe to the three important variables: ESR_ref ESR_ref_editLoaded 1.1 1.1 Y 1.1.1

Re: [R] Remove duplicates from a data frame but with some special requirements

2009-12-16 Thread Gray Calhoun
Hi, Try: subset(Samps, !duplicated(Samps$ESR_ref_edit) | Samps$Loaded == "Y") I'd need specific code to be sure that this is exactly what you want (ie you specify input and desired output), but indexing with a logical vector is probably going to be the solution. Best, Gray On Wed, Dec 16, 2009

[R] Remove duplicates from a data frame but with some special requirements

2009-12-16 Thread gcam
Hi all. So I have a data frame with multiple columns/variables. The first variable is a major sample name for which there are some sub-samples. Currently I have used the following command to remove the duplicates: Samps_working<-Samps[-c(which(duplicated(Samps$ESR_Ref_edit))),] This removes a