Hibernate can determine the correct dialect to use automatically, but in order to do this, it needs a live connection to the database.

253    Asked by AashnaSaito in Python , Asked on Apr 23, 2021

Conditionally Remove Dataframe Rows with R

Question Description 15:


 enter image description here

Using R, how can I write the following logic into the data frame: IF column A = B and Column E = 0, delete row.


Keyword: remove rows in r based on condition

Answered by Dorine Hankey

To conditionally remove rows in r based on condition, you can use the following code:

 A <- c('A','B','A','B','A')
> B <- c('C','D','C','D','C')
> C <- c('E','F','E','F','E')
> D <- c('G','H','G','H','G')
> E <- c(1,0,1,0,1)
> d <- data.frame(A, B, C, D, E)
> d
  A B C D E
1 A C E G 1
2 B D F H 0
3 A C E G 1
4 B D F H 0
5 A C E G 1
According to your condition:
d<-d[!(d$A=="B" & d$E==0),]
> d
  A B C D E
1 A C E G 1
3 A C E G 1
5 A C E G 1

Your Answer

Interviews

Parent Categories