20

I have looked at the answers to Print list without line numbers in R and Prevent print() from outputting list indices in R, but neither seems to prevent R from printing a character string with indices are the left.

Input:

foo = "10 & 1.832171"    
print(foo, row.names=F, quote=F)  

Output:

[1] 10 & 1.832171

Desired Output:

 10 & 1.832171

Is this possible at all?

Community
  • 1
  • 1
merlin2011
  • 71,677
  • 44
  • 195
  • 329
  • Can you please explain the difference between your output and desired output? – Metrics Nov 13 '13 at 00:50
  • 1
    @Metrics - Notice the `[1]` at the beginning of the code box displayed beneath "Output:" – Josh O'Brien Nov 13 '13 at 00:53
  • @ Josh: I didn't notice that. Thanks. – Metrics Nov 13 '13 at 01:23
  • Alternatives to print: `sprintf(fmt, str)`, or `message(...)`, or `cat(...)`, or stamp to file with `write(`, or `sink(`, then copy file to stdout with `cat(`. Also you can write bytes directly to stdout or stderr. Or call C functions like cout from R. – Eric Leschinski Apr 11 '18 at 06:23

1 Answers1

31
> foo = "10 & 1.832171"       
> cat(foo)
10 & 1.832171
Dason
  • 60,663
  • 9
  • 131
  • 148