Re: [R] select from data frame

2017-07-16 Thread Andras Farkas via R-help
thank you David and Bert, these solutions will work for me... Andras  On Saturday, July 15, 2017 6:05 PM, Bert Gunter wrote: ... and here is a slightly cleaner and more transparent way of doing the same thing (setdiff() does the matching) > with(df, setdiff(ID,ID[samples %in% c("B","C"

Re: [R] select from data frame

2017-07-15 Thread Bert Gunter
... and here is a slightly cleaner and more transparent way of doing the same thing (setdiff() does the matching) > with(df, setdiff(ID,ID[samples %in% c("B","C") ])) [1] 3 -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it."

Re: [R] select from data frame

2017-07-15 Thread Bert Gunter
If I understand correctly, no looping (ave(), for()) or type casting (as.character()) is needed -- indexing and matching suffice: > with(df, ID[!ID %in% unique(ID[samples %in% c("B","C") ])]) [1] 3 3 Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming a

Re: [R] select from data frame

2017-07-15 Thread David Winsemius
> On Jul 15, 2017, at 4:01 AM, Andras Farkas via R-help > wrote: > > Dear All, > > wonder if you could please assist with the following > > df<-data.frame(ID=c(1,1,1,2,2,3,3,4,4,5,5),samples=c("A","B","C","A","C","A","D","C","B","A","C")) > > from this data frame the goal is to extract the

[R] select from data frame

2017-07-15 Thread Andras Farkas via R-help
Dear All, wonder if you could please assist with the following df<-data.frame(ID=c(1,1,1,2,2,3,3,4,4,5,5),samples=c("A","B","C","A","C","A","D","C","B","A","C")) from this data frame the goal is to extract the value of 3 from the ID column based on the logic that the ID=3 in the data frame has