Inspecting objects, Debugging, Generating random numbers
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sat, 27 Feb 2016 23:58:41 +0200
changeset 1926 71949d52fd3a
parent 1925 f753d84e666e
child 1927 417ffd620c12
Inspecting objects, Debugging, Generating random numbers
r.rst
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/r.rst	Sat Feb 27 23:58:41 2016 +0200
@@ -0,0 +1,60 @@
+.. -*- coding: utf-8 -*-
+
+===
+ R
+===
+.. contents::
+   :local:
+
+Inspecting objects
+==================
+
+Info about object dimensions::
+
+  length(c(1,2,3))
+  dim(matrix(1:6, 2, 3))
+
+Brief info about any object::
+
+  typeof(str)
+  str(c(1, 2))
+  str(summary)
+
+Brief info about vectors and matrixes::
+
+  summary(1:8)
+  summary(matrix(1:20, 4, 5))
+
+Brief info on datasets and matrixes::
+
+  names(list(colA=1, colB=2))
+
+Debugging
+=========
+
+To mark function for debugging call::
+
+  debug(fun, text = "", condition = NULL)
+  debugonce(fun, text = "", condition = NULL)
+
+To return function to normal execution::
+
+  undebug(fun)
+  isdebugged(fun)
+
+Generating random numbers
+=========================
+
+For each distribution there are exists corresponding generation function, named
+with prefix ``r``::
+
+  rnorm(n, mean = 0, sd = 1)
+  rt(n, df, ncp)
+  rbinom(n, size, prob)
+  rpois(n, lambda)
+  runif(n, min = 0, max = 1)
+
+In order to generate predictable sequences use::
+
+  set.seed(seed, kind = NULL, normal.kind = NULL)
+