0

I tired to print the text %/% in sprintf along with a variable but I'm getting an run time error, could you please assist me how to escape and print the above said string in R program.

Sample code:

x = 5
y = 3

sprintf("The value of (x %/% y) is %d", (x %/% y))

I'm getting the following error

Error in sprintf("The value of (x %/% y) is %d", (x%/%y)) :
  invalid format '%/% y) i'; use format %f, %e, %g or %a for numeric objects
Execution halted

Expected output is

The value of (x %/% y) is 1
B.Balamanigandan
  • 4,713
  • 11
  • 68
  • 130

0 Answers0