--- a/r.rst Sat Feb 27 23:58:41 2016 +0200
+++ b/r.rst Sun Feb 28 01:00:06 2016 +0200
@@ -13,6 +13,8 @@
length(c(1,2,3))
dim(matrix(1:6, 2, 3))
+ ncol(matrix(1:6, 2, 3))
+ nrow(matrix(1:6, 2, 3))
Brief info about any object::
@@ -42,6 +44,33 @@
undebug(fun)
isdebugged(fun)
+You can under to debug mode in any piece of code by calling ``browser``.
+
+``traceback`` prints out the function call stack after an error occurs; does
+nothing if there's no error.
+
+``trace`` allows you to insert debugging code into a function a specific places.
+
+``recover`` allows you to modify the error behavior so that you can browse the
+function call stack.
+
+Profiling
+=========
+
+How long execution of expression takes (in low sec/milisec resolution)::
+
+ system.time(expr, gcFirst = TRUE)
+ unix.time(expr, gcFirst = TRUE)
+
+``Rprof`` function enable global profiling. ``summaryRprof`` function decrypt
+profiling data::
+
+ Rprof() ## start profiling
+ Rprof(NULL) ## suspend profiling
+ Rprof(append = TRUE) ## resume profiling
+ Rprof(NULL) ## end profiling
+ summaryRprof() ## investigate profiling report
+
Generating random numbers
=========================
@@ -58,3 +87,10 @@
set.seed(seed, kind = NULL, normal.kind = NULL)
+Sampling from array::
+
+ sample(x, size, replace = FALSE, prob = NULL)
+ sample.int(n, size = n, replace = FALSE, prob = NULL)
+
+ sample(1:10, 10) ## permutation!!
+ sample(1:10, 100, replace=TRUE)