Print a result without a preceding square bracket in R

Viewed 779
x <- 5+2
print(x)
[1] 7

How to suppress [1] and only print 7? Similarly for characters:

y <- "comp"
print(y)
[1] "comp"

I want to remove both [1] and " ". Any help is appreciated! Thanks!

1 Answers

With cat, it is possible

cat(x, '\n')
7 

Or for characters

cat(dQuote(letters[1], FALSE), '\n')
"a" 
Related