Class: Rserve::REXP::Factor

Inherits:
Integer show all
Defined in:
lib/rserve/rexp/factor.rb

Constant Summary

Constants inherited from Integer

Integer::NA

Constants inherited from Rserve::REXP

MaxDebugItems, MismatchError

Instance Attribute Summary collapse

Attributes inherited from Integer

#payload

Attributes inherited from Vector

#payload

Attributes inherited from Rserve::REXP

#attr

Instance Method Summary collapse

Methods inherited from Integer

#as_doubles, #as_integers, #integer?, #length, #na?, #numeric?, #to_debug_string

Methods inherited from Vector

#==, #length, #na?, #to_a, #vector?

Methods inherited from Rserve::REXP

#as_bytes, #as_double, #as_double_matrix, #as_doubles, #as_float, #as_floats, #as_integer, #as_integers, #as_list, #as_matrix, #as_nested_array, #as_string, #complex?, create_data_frame, #dim, #environment?, #expression?, #get_attribute, #has_attribute?, #inherits?, #integer?, #language?, #length, #list?, #logical?, #na?, #null?, #numeric?, #pair_list?, #raw?, #recursive?, #reference?, #split_array, #string?, #symbol?, #to_debug_string, #to_f, #to_i, #to_ruby, #vector?

Constructor Details

#initialize(ids, levels, attr = nil) ⇒ Factor

Returns a new instance of Factor.



5
6
7
8
9
# File 'lib/rserve/rexp/factor.rb', line 5

def initialize(ids,levels,attr=nil)
  super(ids,attr)
  @levels = (levels.nil?)? Array.new : levels;
  @factor = RFactor.new(@payload, @levels, false, 1)
end

Instance Attribute Details

#levelsObject (readonly)

Returns the value of attribute levels.



4
5
6
# File 'lib/rserve/rexp/factor.rb', line 4

def levels
  @levels
end

Instance Method Details

#as_factorObject



13
14
15
# File 'lib/rserve/rexp/factor.rb', line 13

def as_factor
  @factor
end

#as_stringsObject



16
17
18
# File 'lib/rserve/rexp/factor.rb', line 16

def as_strings
  @factor.as_strings
end

#factor?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/rserve/rexp/factor.rb', line 10

def factor?
  true
end

#to_ruby_internalObject



22
23
24
# File 'lib/rserve/rexp/factor.rb', line 22

def to_ruby_internal
  as_strings
end

#to_sObject



19
20
21
# File 'lib/rserve/rexp/factor.rb', line 19

def to_s
  super+"[#{levels.length}]"
end