Closed Carlotadbm closed 4 years ago
I got this finally… Needed to type the backslash 4 times in order to get its literal interpretation. Class: cmd_question Output: blah… CorrectAnswer: crea_table <- mutate(crea_table, order = str_replace_all(order, "\\.", "")) AnswerTests: omnitest(correctExpr='crea_table <- mutate(crea_table, order = str_replace_all(order, "\\.", ""))') Hint: Adapt the code you just used.
Hi! I'm demo-ing a lesson I prepared in swirlify and I keep getting an error that has to do with escaping characters within regex. In R a double backslash needs to be used for that (for instance "\." forces the literal interpretation of the dot. In the code I'm using, that works perfectly outside of swirlify, but once I run it as an answer I get:
Error: '.' is an unrecognized escape in character string starting ""." | Leaving swirl now. Type swirl() to resume.
This is weird because I'm typing the backslash twice. I'm running this in a tidyverse function and I think this somehow interferes, because I tried using on of the questions of the swirl course "Regular Expressions" and that run smoothly.
This is the code I'm using:
As mentioned, the code in CorrectAnswer works perfectly fine outside swirlify. Other versions of the same line that do not contain escaping backslashes also work ok.
I'm using swirlify 0.5.3 in R 4.0.2 under macOS Catalina 10.15.6. Thanks a lot!