Insert "25 \%" into R for further processing in LaTeX
I want the character variable in R to take the value from, give the word "a" and add "\%" to create a% -sign later in LaTeX.
Usually I would do something like:
a <- 5
paste(a,"\%")
but it fails.
Error: '\%' is an unrecognized escape in character string starting "\%"
Any ideas? A workaround would be to define another command giving% -sign in LaTeX, but I would prefer a solution in R.
source to share
Like many other languages, some characters in strings have different meanings when hidden. One example of this is \n
what does newline mean instead of n
. When you write \%
, R tries to interpret it %
as a special character and doesn't do it. You can try to escape the backslash, so it's just a backslash:
paste(a, "\\%")
You can read up on escape sequences here .
source to share