I am trying to combine a number (x=.9) and a string ("Area Under Curve:") together without printing.
I'm trying just to get the result of: Area Under Curve: .9
cat() and paste() both print the result, however I want to assign the result to a new variable.
I tried using merge() and then toString() the result, but I got an annoying comma between the two objects.
Are there other functions that will combine the objects without printing them?
You can go ahead and combine them using paste
and store in a new variable:
new_var <- paste('Area under a curve:', x)
or even use sprintf
:
new_var <- sprintf('Area under a curve: %f', x)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.