Module: R::IndexedObject

Included in:
DataFrame, Environment, Language, List, Vector
Defined in:
lib/R_interface/rindexed_object.rb

Overview



Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Object


subset a vector with an index


Parameters:

  • index (Array)

    The vector index.



37
38
39
40
41
42
43
44
45
# File 'lib/R_interface/rindexed_object.rb', line 37

def [](index)

  # dealing with double indexing function '[['
  if (index.is_a? Array)
    R::Support.exec_function(R::Support.dbk_index, @r_interop, *index)
  else
    R::Support.exec_function_name("`[`", @r_interop, index)
  end
end

#[]=(index, values) ⇒ Object


subset assign a vector with an index to a value index can span multiple values, for ex., R.c(2, 3, 5)


Parameters:

  • index (Array)

    The vector index

  • values (R::Object)

    The values to assign to the index. Note that



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/R_interface/rindexed_object.rb', line 55

def []=(index, values)

  # dealing with double indexing function '[['
  if (index.is_a? Array)
    setR_name("`[[<-`", *index, values)
  else
    setR_name("`[<-`", index, values)
  end
  
  self
  
end

#sizeObject





72
73
74
# File 'lib/R_interface/rindexed_object.rb', line 72

def size
  length >> 0
end