I unintentionally ran into this and was wondering if there was an explanation for it. In a toy example I put an escape character in a variable level.
library(dplyr)
library(gt)
mt2 <- mutate(mtcars, cylx = ifelse(cyl == 4, "1\2", "2/3"))
Originally I thought it would simply escape the '2' when cyl was 4. However 1\2
actually evaluates to 1\002
. When using View(mt2)
you cannot see it but it does evaluate to a special character when you try and print a table gt::gt(mt2)
. This will show in all printing options but I used gt
as an example.
So my question is why does r assume I wanted 1\2
to evaluate to 1\002
? Shouldn't r throw an error because I did not explicitly write 1\002
(because \2
is not technically an escape character)?