R class() function
kodingwindow@kw:~$ R ... > class(1) [1] "numeric" > class(TRUE) [1] "logical" > class(F) [1] "logical" > class(matrix()) [1] "matrix" > class("Kodingwindow") [1] "character" > class(Sys.time()) [1] "POSIXct" "POSIXt" > class(15L) [1] "integer" > class(15+9i) [1] "complex" > class(charToRaw("Hello World")) [1] "raw"
R typeof() function
> typeof(1) [1] "double" > typeof(1.1) [1] "double" > typeof("Kodingwindow") [1] "character" > typeof(1L) [1] "integer" > typeof(TRUE) [1] "logical" > typeof(F) [1] "logical" > typeof(-3+4i) [1] "complex" > typeof(raw()) [1] "raw" > typeof(NULL) [1] "NULL"
R round() function
> round(3.14) [1] 3 > round(9.87) [1] 10 > round(3.141492,digits=3) [1] 3.141 > raw(10) [1] 00 00 00 00 00 00 00 00 00 00
R sample() function
> sample(1:36) [1] 9 15 20 16 3 30 26 4 5 10 33 36 24 32 12 19 22 8 13 34 2 35 23 18 29 [26] 1 14 17 6 7 28 31 11 27 25 21 > sample(1:36,size=1) [1] 2 > sample(1:36,size=1) [1] 16 > sample(1:36,size=1) [1] 5 > sample(1:36,size=5) [1] 7 13 33 6 22
R replicate() function
> replicate(3,'Kodingwindow') [1] "Kodingwindow" "Kodingwindow" "Kodingwindow" > replicate(3,1:6) [,1] [,2] [,3] [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [4,] 4 4 4 [5,] 5 5 5 [6,] 6 6 6
R format() function
> format(3.141492,digits=3) [1] "3.14" > format("Kodingwindow",width=20) [1] "Kodingwindow " > format("Kodingwindow",width=20,justify="")Error in match.arg(justify) : 'arg' should be one of “left”, “right”, “centre”, “none” > format("Kodingwindow",width=20,justify="l") [1] "Kodingwindow " > format("Kodingwindow",width=20,justify="c") [1] " Kodingwindow " > format("Kodingwindow",width=20,justify="r") [1] " Kodingwindow" > format("Kodingwindow",width=20,justify="n") [1] "Kodingwindow"
Advertisement