Tuesday 28 July 2015

R: sprintf(): Assemble string in formatted manner

It is a wrapper for the C function sprintf,  returns a character vector containing a formatted combination of text and variable values.

Usage
sprintf(fmt, ...)
fmt : a character vector of format strings, each of up to 8192 bytes.

... : values to be passed into fmt. 

> x <- sprintf("My name is %s, I am %d years old", "Hari Krishna", 25)
> x
[1] "My name is Hari Krishna, I am 25 years old"


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment