equal
deleted
inserted
replaced
11 |
11 |
12 Info about object dimensions:: |
12 Info about object dimensions:: |
13 |
13 |
14 length(c(1,2,3)) |
14 length(c(1,2,3)) |
15 dim(matrix(1:6, 2, 3)) |
15 dim(matrix(1:6, 2, 3)) |
|
16 ncol(matrix(1:6, 2, 3)) |
|
17 nrow(matrix(1:6, 2, 3)) |
16 |
18 |
17 Brief info about any object:: |
19 Brief info about any object:: |
18 |
20 |
19 typeof(str) |
21 typeof(str) |
20 str(c(1, 2)) |
22 str(c(1, 2)) |
40 To return function to normal execution:: |
42 To return function to normal execution:: |
41 |
43 |
42 undebug(fun) |
44 undebug(fun) |
43 isdebugged(fun) |
45 isdebugged(fun) |
44 |
46 |
|
47 You can under to debug mode in any piece of code by calling ``browser``. |
|
48 |
|
49 ``traceback`` prints out the function call stack after an error occurs; does |
|
50 nothing if there's no error. |
|
51 |
|
52 ``trace`` allows you to insert debugging code into a function a specific places. |
|
53 |
|
54 ``recover`` allows you to modify the error behavior so that you can browse the |
|
55 function call stack. |
|
56 |
|
57 Profiling |
|
58 ========= |
|
59 |
|
60 How long execution of expression takes (in low sec/milisec resolution):: |
|
61 |
|
62 system.time(expr, gcFirst = TRUE) |
|
63 unix.time(expr, gcFirst = TRUE) |
|
64 |
|
65 ``Rprof`` function enable global profiling. ``summaryRprof`` function decrypt |
|
66 profiling data:: |
|
67 |
|
68 Rprof() ## start profiling |
|
69 Rprof(NULL) ## suspend profiling |
|
70 Rprof(append = TRUE) ## resume profiling |
|
71 Rprof(NULL) ## end profiling |
|
72 summaryRprof() ## investigate profiling report |
|
73 |
45 Generating random numbers |
74 Generating random numbers |
46 ========================= |
75 ========================= |
47 |
76 |
48 For each distribution there are exists corresponding generation function, named |
77 For each distribution there are exists corresponding generation function, named |
49 with prefix ``r``:: |
78 with prefix ``r``:: |
56 |
85 |
57 In order to generate predictable sequences use:: |
86 In order to generate predictable sequences use:: |
58 |
87 |
59 set.seed(seed, kind = NULL, normal.kind = NULL) |
88 set.seed(seed, kind = NULL, normal.kind = NULL) |
60 |
89 |
|
90 Sampling from array:: |
|
91 |
|
92 sample(x, size, replace = FALSE, prob = NULL) |
|
93 sample.int(n, size = n, replace = FALSE, prob = NULL) |
|
94 |
|
95 sample(1:10, 10) ## permutation!! |
|
96 sample(1:10, 100, replace=TRUE) |