Print string and variable contents on the same line in R

user2015601 picture user2015601 · Mar 23, 2013 · Viewed 454.3k times · Source

Is there a way to print text and variable contents on the same line? For example,

wd <- getwd()
print("Current working dir: ", wd)

I couldn't find anything about the syntax that would allow me to do this.

Answer

agstudy picture agstudy · Mar 23, 2013

You can use paste with print

print(paste0("Current working dir: ", wd))

or cat

cat("Current working dir: ", wd)