R Print


R print() funtion prints out the argument to the screen. Parameter digits defines minimal number of significant digits, na.print indicates NA values output format, similarly zero.print defines how zero (0) should be printed.

Let's create a small data frame, and print it out:

>x <- cars[2:5,]
>print(x)

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


Using digits parameter:

>y <- x/7
>print(y, digits=4)

speed dist
2 0.5714 1.4286
3 1.0000 0.5714
4 1.0000 3.1429
5 1.1429 2.2857


Using na.print parameter:

>x <- matrix(c(4, NA, NA, 0, 8, NA, 21, 0, 0), nrow=3, byrow=TRUE)
>print(x,na.print="")

[,1] [,2] [,3]
[1,] 4
[2,] 0 8
[3,] 21 0 0


endmemo.com © 2024  | Terms of Use | Privacy | Home