- Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathdataframe.rb
35 lines (34 loc) · 908 Bytes
/
dataframe.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#==Synopsis
#
#This example shows the use of the Class conversion system to convert
#dataframes into the Ruby DataFrame class
#
# require 'rsruby'
# require 'rsruby/dataframe'
#
# r = RSRuby.instance
#
#Here we just set up a simple class table that returns a new DataFrame
#object when a dataframe is returned by R
#
# r.class_table['data.frame'] = lambda{|x| DataFrame.new(x)}
# RSRuby.set_default_mode(RSRuby::CLASS_CONVERSION)
#
#We then create a dataframe object to test the conversion
# e = r.as_data_frame(:x => {'foo' => [4,5,6], 'bar' => ['X','Y','Z']})
#
#Using some of the ERObj and DataFrame class capabilities we can access the
#dataframe data in various ways
#
# puts e
# puts e.foo.join(" ")
# puts e.bar.join(" ")
# puts e.rows.join(" ")
# puts e.columns.join(" ")
#
# puts e.baz.join(" ")
#
# puts e['foo'].join(" ")
if__FILE__ == $0
eval(IO.read($0).gsub(/^\#\s\s/,''))
end