Class: Rserve::REXP::Vector
- Inherits:
-
Rserve::REXP
- Object
- Rserve::REXP
- Rserve::REXP::Vector
- Defined in:
- lib/rserve/rexp/vector.rb
Constant Summary
Constants inherited from Rserve::REXP
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Attributes inherited from Rserve::REXP
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#length ⇒ Object
returns the length of the vector (i.e. the number of elements).
-
#na? ⇒ Boolean
returns a boolean vector of the same length as this vector with
true
for NA values andfalse
for any other values. -
#to_a ⇒ Object
Retrieves values as Ruby array NA will be replaced with nils.
- #to_ruby_internal ⇒ Object
- #vector? ⇒ Boolean
Methods inherited from Rserve::REXP
#as_bytes, #as_double, #as_double_matrix, #as_doubles, #as_factor, #as_float, #as_floats, #as_integer, #as_integers, #as_list, #as_matrix, #as_nested_array, #as_string, #as_strings, #complex?, create_data_frame, #dim, #environment?, #expression?, #factor?, #get_attribute, #has_attribute?, #inherits?, #initialize, #integer?, #language?, #list?, #logical?, #null?, #numeric?, #pair_list?, #raw?, #recursive?, #reference?, #split_array, #string?, #symbol?, #to_debug_string, #to_f, #to_i, #to_ruby
Constructor Details
This class inherits a constructor from Rserve::REXP
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
4 5 6 |
# File 'lib/rserve/rexp/vector.rb', line 4 def payload @payload end |
Instance Method Details
#==(o) ⇒ Object
5 6 7 8 |
# File 'lib/rserve/rexp/vector.rb', line 5 def ==(o) #p "Comparing #{self.inspect} with #{o.inspect} gives #{self.payload==o.payload and self.attr==o.attr}" self.class==o.class and self.payload==o.payload and self.attr==o.attr end |
#length ⇒ Object
returns the length of the vector (i.e. the number of elements)
12 13 |
# File 'lib/rserve/rexp/vector.rb', line 12 def length end |
#na? ⇒ Boolean
returns a boolean vector of the same length as this vector with true
for NA values and false
for any other values
19 20 |
# File 'lib/rserve/rexp/vector.rb', line 19 def na? end |
#to_a ⇒ Object
Retrieves values as Ruby array NA will be replaced with nils
24 25 26 |
# File 'lib/rserve/rexp/vector.rb', line 24 def to_a @payload.map {|v| na?(v) ? nil : v } end |
#to_ruby_internal ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/rserve/rexp/vector.rb', line 27 def to_ruby_internal if @payload.nil? or @payload.size==0 nil elsif @payload.size==1 @payload[0] else @payload.map {|v| na?(v) ? nil : v} end end |
#vector? ⇒ Boolean
14 15 16 |
# File 'lib/rserve/rexp/vector.rb', line 14 def vector? true end |