r.rst
changeset 1926 71949d52fd3a
child 1927 417ffd620c12
equal deleted inserted replaced
1925:f753d84e666e 1926:71949d52fd3a
       
     1 .. -*- coding: utf-8 -*-
       
     2 
       
     3 ===
       
     4  R
       
     5 ===
       
     6 .. contents::
       
     7    :local:
       
     8 
       
     9 Inspecting objects
       
    10 ==================
       
    11 
       
    12 Info about object dimensions::
       
    13 
       
    14   length(c(1,2,3))
       
    15   dim(matrix(1:6, 2, 3))
       
    16 
       
    17 Brief info about any object::
       
    18 
       
    19   typeof(str)
       
    20   str(c(1, 2))
       
    21   str(summary)
       
    22 
       
    23 Brief info about vectors and matrixes::
       
    24 
       
    25   summary(1:8)
       
    26   summary(matrix(1:20, 4, 5))
       
    27 
       
    28 Brief info on datasets and matrixes::
       
    29 
       
    30   names(list(colA=1, colB=2))
       
    31 
       
    32 Debugging
       
    33 =========
       
    34 
       
    35 To mark function for debugging call::
       
    36 
       
    37   debug(fun, text = "", condition = NULL)
       
    38   debugonce(fun, text = "", condition = NULL)
       
    39 
       
    40 To return function to normal execution::
       
    41 
       
    42   undebug(fun)
       
    43   isdebugged(fun)
       
    44 
       
    45 Generating random numbers
       
    46 =========================
       
    47 
       
    48 For each distribution there are exists corresponding generation function, named
       
    49 with prefix ``r``::
       
    50 
       
    51   rnorm(n, mean = 0, sd = 1)
       
    52   rt(n, df, ncp)
       
    53   rbinom(n, size, prob)
       
    54   rpois(n, lambda)
       
    55   runif(n, min = 0, max = 1)
       
    56 
       
    57 In order to generate predictable sequences use::
       
    58 
       
    59   set.seed(seed, kind = NULL, normal.kind = NULL)
       
    60