I'd like to select the rows in a data frame where two columns, A and B are equal. I have tried this:
A <- c(0,1,2)
B <- c(2,1.000001,0)
df <- as.data.frame(cbind(A,B))
subset(df,A==B) # does not work
# [1] A B
# <0 rows> (or 0-length row.names)
subset(df,round(A,3)==round(B,3)) # does work
# A B
# 2 1 1.000001
subset(df,A==B)
mteq <- mtcars[mtcars$gear==mtcars$carb, ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With