Open in App
Not now

# Print the Argument to the Screen in R Programming – print() Function

• Last Updated : 24 Jun, 2020

`print()` function in R Language is used to print out the argument to the screen.

Syntax: print(x, digits, na.print)

Parameters:
x: specified argument to be displayed
digits: defines minimal number of significant digits
na.print: indicates NA values output format

Example 1:

 `# R program to illustrate ` `# print function ` ` `  `# Creating a data frame ` `x <``-` `cars[``1``:``5``, ] ` ` `  `# Calling the print() function ` `# to print the above data frame ` `print``(x) `

Output:

```  speed dist
1     4    2
2     4   10
3     7    4
4     7   22
5     8   16
```

Example 2:

 `# R program to illustrate ` `# print function ` ` `  `# Initializing a number ` `x <``-` `15` `/` `7` ` `  `# Calling the print() function ` `# using digits parameter ` `print``(x, digits ``=` `2``) ` `print``(x, digits ``=` `3``) ` `print``(x, digits ``=` `4``) `

Output:

```[1] 2.1
[1] 2.14
[1] 2.143
```

Example 3:

 `# R program to illustrate ` `# print function ` ` `  `# Creating a matrix ` `x <``-` `matrix(c(``2``, NA, ``5``, NA, ``8``, NA, ``22``, ``67``, ``43``), ` `               ``nrow ``=` `3``, byrow ``=` `TRUE) ` ` `  `# Calling the print() function ` `# using na.print parameter ` `print``(x, na.``print` `=` `"") `

Output:

```     [, 1] [, 2] [, 3]
[1, ]    2         5
[2, ]         8
[3, ]   22   67   43
```

My Personal Notes arrow_drop_up
Related Articles