3
A doubt, as I print (print
) a variable x
after a text in R.
As in the python
you do.
print (f"seu numero é",x)
3
A doubt, as I print (print
) a variable x
after a text in R.
As in the python
you do.
print (f"seu numero é",x)
7
Using the paste
.
lenesson <- 10
paste("Seu número é", lenesson)
Output.
[1] "Your number is 10"
4
Here are two options:
x <- 10
cat("seu numero é", x, "\n")
#seu numero é 10
sprintf("seu número é %g", x)
#[1] "seu número é 10"
Note that cat
does not put the string between quotes.
See also the formats in help("sprintf")
.
3
The R
does not have this syntax of f-string, but the package Glue offers something similar. With it we could do something like this:
x <- 10
glue::glue("seu numero é {x}")
#> seu numero é 10
It works so that it evaluates codes r
inside the parts inside the keys inside the strings.
Browser other questions tagged r variables
You are not signed in. Login or sign up in order to post.
Many thanks
– Lenesson Ribeiro