How similar is print command in R to printf in C -


how similar print command in r printf in c? want write command printf(%s, variable) in r? suggestions how that?

my code:

v <- "abc" print(sprintf(%s, v) 

error: unexpected input in "print(sprintf(%s, v)"

you have 2 errors:

r> v <- "abc" r> print(sprintf("%s", v)) [1] "abc" 

the first not write format string string in quotes. second missing closing parenthesis.

but want argument cat() want end newline in 1 of 2 places:

r> cat(sprintf("%s", v), "\n") abc  r> cat(sprintf("%s\n", v)) abc r>  

Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -