class R::DataFrame

Public Instance Methods

[]=(index, *args) click to toggle source
# File lib/R_interface/rdata_frame.rb, line 53
def []=(index, *args)
  values = args[-1]
  idx2 = (args.size > 1)? args[-2] : false
  
  # dealing with double indexing function '[['
  if (index.is_a? Array)
    setR_name("`[[<-`", R.empty_symbol, *index, values)
  else
    idx2 ? setR_name("`[<-`", index, idx2, values) :
      setR_name("`[<-`", R.empty_symbol, index, values)
  end
  
  self
  
end
each_column() { |self, names >> 0| ... } click to toggle source
# File lib/R_interface/rdata_frame.rb, line 89
def each_column
  
  # ncol is the R function that return the number of columns in the dataset.  This
  # function returns a R::Vector, so we need to extract its first element (<< 0)
  (1..ncol >> 0).each do |i|
    yield self[:all, i], self.names[i] >> 0
  end
  
end
each_row() { |self, rownames >> 0| ... } click to toggle source
# File lib/R_interface/rdata_frame.rb, line 74
def each_row

  # nrow is the R function that return the number of rows in the dataset.  This
  # function returns a R::Vector, so we need to extract its first element (<< 0)
  (1..nrow >> 0).each do |i|
    yield self[i, :all], self.rownames[i] >> 0
  end

end
method_missing_assign(column_name, arg) click to toggle source
# File lib/R_interface/rdata_frame.rb, line 41
def method_missing_assign(column_name, arg)
  setR_name("`[<-`", R.empty_symbol, column_name, arg)
end
qplot(*args) click to toggle source
# File lib/R_interface/rdata_frame.rb, line 33
def qplot(*args)
  print R.qplot(*args, data: self)
end