Module: R::MDIndexedObject
Overview
Module to be included for objects that have multi dimensional indices, such as array and dataframe
Instance Method Summary collapse
-
#[](*index) ⇒ Object
-------------------------------------------------------------------------------------- Index a DataFrame by using [] --------------------------------------------------------------------------------------.
Instance Method Details
#[](*index) ⇒ Object
Index a DataFrame by using []
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/R_interface/rmd_indexed_object.rb', line 37 def [](*index) if (index.size > 1) # DataFrame single-cell only when both indices are scalar (one row, one column): use [[ so R returns scalar single_cell = index.size == 2 && self.is_a?(::R::DataFrame) && index[0].is_a?(::Integer) && (index[1].is_a?(::Integer) || index[1].is_a?(::String)) fn = single_cell ? R::Support.dbk_index : R::Support.md_index R::Support.exec_function(fn, @r_interop, *index) else super(*index) end end |