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
Post a Comment