R – Print string and variable contents on the same line in R

printingr

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.

Best Answer

You can use paste with print

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

or cat

cat("Current working dir: ", wd)