I have a dataframe like this:
ID <- c("A","B","C","D","E","F","G","H","I")
Measurement <- c('Length',NA,NA,NA,'Length','Length',NA,NA,'Length')
PT <- c(27,35,38,22,35,39,7,15,33)
df <- data.frame(ID,Measurement,PT)
Limit <- 25
I am trying to subset this dataframe using the limit as the condition so that I exclude any data that has a ("PT" value > limit AND Measuremnent = NA).
Note: However I still want to include any data that has PT > Limit but with a Measurement type in it. In this case, its the length.
I am trying to do it this way but I get an error
df3 <- !subset(df3,df3$PT >= Limit & df3$Measurement == '')
My desired Output is
ID Measurement PT
1 A Length 27
2 D <NA> 22
3 E Length 35
4 F Length 39
5 G <NA> 7
6 H <NA> 15
7 I Length 33
I know this is pretty simple but I missing the logic somewhere. Could someone point me in the right direction?
df[!is.na(df$Measurement) | df$PT < Limit,]?