Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

printf

C-style formatted output


Description

C-style formatted output.

Usage

## Default S3 method:
printf(fmt, ..., sep="", file="")

Arguments

fmt

A character vector of format strings. See same argument for sprintf().

...

Additional arguments sprintf().

sep

A character vector of strings to append after each element.

file

A connection, or a character of a file to print to. See same argument for cat().

Value

Returns nothing.

Author(s)

Henrik Bengtsson

See Also

For C-style formatting of character strings, see sprintf().

Examples

cat("Hello world\n")
  printf("Hello world\n")

  x <- 1.23
  cat(sprintf("x=%.2f\n", x))
  printf("x=%.2f\n", x)

  y <- 4.56
  cat(sprintf(c("x=%.2f\n", "y=%.2f\n"), c(x,y)), sep="")
  printf(c("x=%.2f\n", "y=%.2f\n"), c(x,y))

R.utils

Various Programming Utilities

v2.10.1
LGPL (>= 2.1)
Authors
Henrik Bengtsson [aut, cre, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.