R String Format

In this tutorial you will learn about the R String Format and its application with practical example.

R String Format

Sometime we may want to convert a number or string into any specific format. In R, the format() function is used to format numbers and strings into specified format.

Table Of Contents

Syntax:-

Above is the general syntax of format() function, here –

str:- It is a vector input representing a string.

digits:- Number of digits to be displayed.

nsmall:- It represents the min. number of digits after the decimal point.

scientific:- It is set to TRUE to display scientific notation.

width:- It represents the min. width to be displayed, it allows padding blank space in the beginning.

justify:- It is used to set display of the string to left, right or center.

Example:-

Output:-

r_string_format

In this tutorial we have learn about the R String Format and its application with practical example. I hope you will like this tutorial.