0

I want to insert a delta inside a print command in R. Expect \delta all the greek letters are coming without any error. However, the following error is prompted when trying to print \delta using the sprintf command. Can you help?

I tried searching for an answer and found one. But the solution was to use a forward slash which obviously won't work in my case. enter image description here

  • Use `print("$\\delta$")` Please [do not post code or data in images](https://meta.stackoverflow.com/q/285551/2372064) – MrFlick Jan 27 '23 at 16:47
  • Not working it is just typing "delta" after an enter – user19107602 Jan 27 '23 at 16:49
  • Oh, are you trying to use latex code in just the regular R console? What other letters are working? I wouldn't expect any latex markup to work in the console unless you are doing some sort of rmarkdown document. We need more context here. But either way, a single slash in a string is an escape character and needs to be properly followed by an expected escape sequence. – MrFlick Jan 27 '23 at 16:53
  • Ok. Let me try to explain. So what I need to print is " = 100". So I am doing it by the following command: sprintf("$\delta = %f$", 100). Same is working with alpha, beta etc – user19107602 Jan 27 '23 at 16:58
  • 1
    That's not doing what you think it's doing. It just so happens that `\a` is the escape for the bell character and `\b` is the escape for the backspace character. There is no excape defined for `\d` so you get the error. It only has to do with the first character. It would be better to show the larger context of what your markdown document looks like. Is this in a code block? Are you sure the others actually render correctly? – MrFlick Jan 27 '23 at 17:02
  • Thank you for your patience. To be frank, this is part of a school project, and I am using Jupyter notebook to make a report. As part of printing an answer, I just need to print " = 100". That is all I need. Of course, this 100 is a variable so, I can't use markdown. – user19107602 Jan 27 '23 at 17:16
  • Can't you just copy ` =` into the string? Assuming you are using utf-8 that character will probably print out in the notebook. Just copy/paste what ever unicode characters you want into the document. – MrFlick Jan 27 '23 at 18:01

0 Answers0