KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In ?agrep ( grep with fuzzy matching) it mentions that I can set the argument fixed=FALSE to let my pattern be interpreted as a regular expression. However, I can't get it to work! agrep('(asdf|fdsa)', 'asdf', fixed=F) # integer(0) The above should match as the regular expression "(asdf|fdsa)" exactly matches the test string "asdf" in this case. To confirm: grep('(asdf|fdsa)', 'asdf', fixed=F) # 1 : it does match with grep And even more confusingly, adist correctly gives the distance between the pattern and string as 0, meaning that agrep should definitely return 1 rather than integer(0) (there's no possibility that 0 is greater than the default max.dist = 0.1 ). adist('(asdf|fdsa)', 'asdf', fixed=F) # [,1] # [1,] 0 Why is this not working? Is there something I don't understand? A workaround? I'm happy to use adist , but am not entirely sure how to convert agrep 's default max.distance=0.1 parameter to adist 's corresponding parameter. (yes, I'm stuck on an old computer that can't do better than R 2.15.2) > sessionInfo() R version 2.15.2 (2012-10-26) Platform: i686-redhat-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_AU.utf8 LC_NUMERIC=C [3] LC_TIME=en_AU.utf8 LC_COLLATE=en_AU.utf8 [5] LC_MONETARY=en_AU.utf8 LC_MESSAGES=en_AU.utf8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base
Tags (comma-separated)
Save Edits
Cancel