How to print text and variables on one line in r

Is there a way to print text and variables on the same line in r

eg,

a="Hello" b="EKA" c="123456" print("$a !! my name is $b and my number is $c") 

out put will be like this:

 Hello !! my name is EKA and my number is 123456 
+11
source share
2 answers

I would suggest using the sprintf function. The advantage of this function is that the variables can be of any class (here c is numeric).

 a="Hello" b="EKA" c=123456 sprintf("%s !! my name is %s and my number is %i", a, b, c) 
+13
source

print (paste ("You selected the following file name:", fileName)) will do the job

0
source

All Articles