Class: R::DataFrame
- Includes:
- IndexedObject, MDIndexedObject
- Defined in:
- lib/R_interface/rdata_frame.rb
Instance Attribute Summary
Attributes inherited from Object
Instance Method Summary collapse
-
#[]=(index, *args) ⇒ Object
————————————————————————————– subset assign a vector with an index to a value index can span multiple values, for ex., R.c(2, 3, 5) ————————————————————————————–.
-
#each_column ⇒ Object
————————————————————————————– Goes through each column of the dataframe and return the whole column as the first element and the column name (Ruby string) as the second ————————————————————————————–.
-
#each_row ⇒ Object
————————————————————————————– Goes through each row of the dataframe and return the whole row as the first element and the row name (Ruby string) as the second ————————————————————————————–.
-
#method_missing_assign(column_name, arg) ⇒ Object
————————————————————————————–.
-
#qplot(*args) ⇒ Object
————————————————————————————– Calls the R.qplot adding the data: parameter ————————————————————————————–.
Methods included from MDIndexedObject
Methods included from IndexedObject
Methods inherited from Object
#==, #_, #attr=, build, #comment, #comment=, #dim, #dim=, #dimnames, #dimnames=, #eql, #initialize, #method_missing, #names, #names=, #pp, #pretty_print, #rclass, #rclass=, #row__names, #row__names=, #setR, #setR_name, #to_s, #tsp, #tsp=
Constructor Details
This class inherits a constructor from R::Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class R::Object
Instance Method Details
#[]=(index, *args) ⇒ Object
subset assign a vector with an index to a value index can span multiple values, for ex., R.c(2, 3, 5)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/R_interface/rdata_frame.rb', line 54 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 ⇒ Object
Goes through each column of the dataframe and return the whole column as the first element and the column name (Ruby string) as the second
90 91 92 93 94 95 96 97 98 |
# File 'lib/R_interface/rdata_frame.rb', line 90 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 ⇒ Object
Goes through each row of the dataframe and return the whole row as the first element and the row name (Ruby string) as the second
75 76 77 78 79 80 81 82 83 |
# File 'lib/R_interface/rdata_frame.rb', line 75 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) ⇒ Object
42 43 44 |
# File 'lib/R_interface/rdata_frame.rb', line 42 def method_missing_assign(column_name, arg) setR_name("`[<-`", R.empty_symbol, column_name, arg) end |