alex_r 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ # Goal: To make a panel of pictures.
2
+
3
+ par(mfrow=c(3,2)) # 3 rows, 2 columns.
4
+
5
+ # Now the next 6 pictures will be placed on these 6 regions. :-)
6
+
7
+ # Let me take some pains on the 1st
8
+ plot(density(runif(100)), lwd=2)
9
+ text(x=0, y=0.2, "100 uniforms") # Showing you how to place text at will
10
+ abline(h=0, v=0)
11
+ # All these statements effect the 1st plot.
12
+
13
+ x=seq(0.01,1,0.01)
14
+ par(col="blue") # default colour to blue.
15
+
16
+ # 2 --
17
+ plot(x, sin(x), type="l")
18
+ lines(x, cos(x), type="l", col="red")
19
+
20
+ # 3 --
21
+ plot(x, exp(x), type="l", col="green")
22
+ lines(x, log(x), type="l", col="orange")
23
+
24
+ # 4 --
25
+ plot(x, tan(x), type="l", lwd=3, col="yellow")
26
+
27
+ # 5 --
28
+ plot(x, exp(-x), lwd=2)
29
+ lines(x, exp(x), col="green", lwd=3)
30
+
31
+ # 6 --
32
+ plot(x, sin(x*x), type="l")
33
+ lines(x, sin(1/x), col="pink")
@@ -0,0 +1,3 @@
1
+ require 'alex_r'
2
+
3
+ AlexR.execute("panel_of_pictures.pdf", "panel_of_pictures.r")
@@ -0,0 +1,7 @@
1
+ require 'alex_r'
2
+
3
+ AlexR.execute("panel_of_pictures.pdf") do |r|
4
+ File.open("panel_of_pictures.r") do |file|
5
+ r << file.readlines.join("\n")
6
+ end
7
+ end
data/lib/alex_r.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'open3'
2
+
3
+ class AlexR
4
+ def self.execute(output_file, input_file_path=nil)
5
+ stdin, stdout, stderr = Open3.popen3('Rscript -')
6
+ stdin << "pdf('#{output_file}')\n"
7
+ if input_file_path
8
+ File.open(input_file_path) do |file|
9
+ until file.eof?
10
+ stdin << "#{file.readline}\n"
11
+ end
12
+ end
13
+ else
14
+ yield(stdin) if block_given?
15
+ end
16
+ stdin.close
17
+
18
+ errors = stderr.readlines
19
+ raise errors.join("\n") unless errors.empty?
20
+ return stdout.readlines.join("\n")
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alex_r
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Jae Lee
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-09 00:00:00 +00:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Allows you execute RScript
22
+ email: jlee@yetitrails.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/alex_r.rb
31
+ - example/r_from_file.rb
32
+ - example/r_from_string.rb
33
+ - example/panel_of_pictures.r
34
+ has_rdoc: true
35
+ homepage: https://github.com/forward/AlexR
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.3.7
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: alex_r is a thin wrapper around RScript
66
+ test_files: []
67
+