Class: DataFrame

Inherits:
ERObj show all
Defined in:
lib/rsruby/dataframe.rb

Instance Method Summary collapse

Methods inherited from ERObj

#as_r, #initialize, #lcall, #to_s

Constructor Details

This class inherits a constructor from ERObj

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(attr) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rsruby/dataframe.rb', line 61

def method_missing(attr)
  attr = attr.to_s
  mode = RSRuby.get_default_mode
  RSRuby.set_default_mode(RSRuby::BASIC_CONVERSION)
  column_names = @r.colnames(@robj)
  if attr == column_names or column_names.include?(attr)
    RSRuby.set_default_mode(mode)
    return @r['$'].call(@robj,attr.to_s)
  end

  #? Not sure what here...
  RSRuby.set_default_mode(mode)
  return super(attr)

end

Instance Method Details

#columnsObject

Returns an array of the column names used in the R data frame.



55
56
57
58
59
# File 'lib/rsruby/dataframe.rb', line 55

def columns
  cols = @r.colnames(@robj)
  cols = [cols] unless cols.class == 'Array'
  return cols
end

#rowsObject

Returns an array of the row names used in the R data frame.



50
51
52
# File 'lib/rsruby/dataframe.rb', line 50

def rows
  return @r.attr(@robj, 'row.names')
end