I'm looking for how to do printf in r, ie I want to type:
printf("hello %d\n", 56 )
and get the same output as typing:
print(sprintf("hello %d\n", 56 )
I've read the following links:
... so I'm aware I could use cat("hello", 56)
, and that's probably what I will do, but just wondering if there is some shortcut way of writing print(sprintf(...))
?
Sorry if this question is a duplicate (I dont know). It's awfully hard to search for 'printf r', since it returns results for php, c, ...
[r] printf
, not justr printf
.print(sprintf("hello %d\n", 56 ))
results in"hello 56\n"
. Can you please explain why you want the "\n" to show up in the output as a literal? That is NOT what printf is intuitively supposed to show based on its behavior in other programming languages, notably C. Please change your question so that it makes sense.