[R] Printing linefeeds using sprintf

Haynes, Maurice (NIH/NICHD) haynesm at cfr.nichd.nih.gov
Wed Aug 13 03:04:04 CEST 2003

Is there a way to print complex, multi-line text and numeric output with
good control of the field width and precision of numeric values?  In the
first example in the R Documentation for the sprintf function, there appears
to be a linefeed code "\n", but it is printed literally.

> sprintf("%s is %f feet tall\n", "Sven", 7)
[1] "Sven is 7.000000 feet tall\n"


O. Maurice Haynes
National Institute of Child Health and Human Development
Child and Family Research Section
6705 Rockledge Drive
Bethesda, MD  20892
Voice: 301-496-8180
Fax: 301-496-2766
E-Mail: mh192j at nih.gov

More information about the R-help mailing list