Re: [R] subset data frame problem

2021-12-13 Thread Kai Yang via R-help
Thans Richard, it works well. --- Kai On Monday, December 13, 2021, 04:00:33 AM PST, Richard O'Keefe wrote: You want to DELETE rows satisfying the condition P & Q.The subset() function requires an expression saying whatyou want to RETAIN, so you need subset(PD, !(P & Q)). test <- subs

Re: [R] subset data frame problem

2021-12-13 Thread Richard O'Keefe
You want to DELETE rows satisfying the condition P & Q. The subset() function requires an expression saying what you want to RETAIN, so you need subset(PD, !(P & Q)). test <- subset(PD, !(Class == "1st" & Survived == "No")) By de Morgan's laws, !(P & Q) is the same as (!P) | (!Q) so you could als

Re: [R] subset data frame problem

2021-12-12 Thread Jeff Newmiller
Use one ampersand, not two. And post plain text. On December 12, 2021 8:30:11 PM PST, Kai Yang via R-help wrote: >Hi R team,I want to delete records from a data frame if Class = '1st' and >Survived = 'No'. I wrote the code below, test <- subset(PD, Class != '1st' && >Survived != 'No') >but th

[R] subset data frame problem

2021-12-12 Thread Kai Yang via R-help
Hi R team,I want to delete records from a data frame if Class = '1st' and Survived = 'No'. I wrote the code below, test <- subset(PD, Class != '1st' && Survived != 'No') but the code return a wrong result. Can someone help me for this?  Thanks,Kai [[alternative HTML version deleted]] ___