I have a big dataset with some columns representing amount with Decimal(5,2) format:
DF
Name|Salary|State
Joe|12345.34|AZ
Mac|3423.67|CT
Lilly|12342.345|CA
Clearly only Joe qualifies the criteria so after subsetting I should get records NOT matching the criteria on Salary Column.Thus the result should be
Name|Salary|State
Mac|3423.67|CT
Lilly|12342.345|CA
I want to use subset function:
subset(grepl("^[[:digit:]]{,5}\\.[[:digit:]]{,2}$",DF$Salary)
OR
subset(grepl("[[:digit:]]{,5}\\.[[:digit:]]{,2}",DF)
subset(grepl("[[:digit:]]{,5}[.][[:digit:]]{,2}",DF)
None of these give me correct result. On further investigation I found that the grepl itself doesnt work properly.
Example:
x <- "12345.45"
grepl("[[:digit:]]{,5}\\.[[:digit:]]{,2}",x) # TRUE
grepl("[[:digit:]]{,4}\\.[[:digit:]]{,2}",x) # TRUE
grepl("[[:digit:]]{,4}[.][[:digit:]]{,2}",x) # TRUE