Browse code

Rprofile - v0.3 - Add less function

Fred authored on03/11/2014 18:13:28
Showing1 changed files
... ...
@@ -1,8 +1,8 @@
1 1
 # Title: .Rprofile
2 2
 # Author: Frédéric CHEVALIER <f15.chevalier@gmail.com>
3
-# Version: 0.2
3
+# Version: 0.3
4 4
 # Created in: 2014-07-06
5
-# Modified in: 2014-10-21
5
+# Modified in: 2014-11-03
6 6
 
7 7
 
8 8
 
... ...
@@ -19,6 +19,7 @@
19 19
 # Versions #
20 20
 #==========#
21 21
 
22
+# v0.3 - 2014-11-03: less function added
22 23
 # v0.2 - 2014-10-21: bug correction about width of terminal
23 24
 # v0.1 - 2014-08-06: bug correction about interactivity (curly brackets missing)
24 25
 # v0.0 - 2014-07-06: creation
... ...
@@ -113,6 +114,15 @@ if (capabilities()[["tcltk"]] && require(tcltk2, quietly=TRUE)) {
113 114
 # Exit
114 115
 .startup$bye <- function () {q("no")}
115 116
 
117
+# Less emulation
118
+# source: http://stackoverflow.com/questions/3503811/is-there-an-r-equivalent-to-the-bash-command-more
119
+.startup$less <- function(x) {
120
+    file <- tempfile()
121
+    sink(file); on.exit(sink())
122
+    print(x)
123
+    file.show(file, delete.file = T)
124
+}
125
+
116 126
 
117 127
 
118 128
 #=========#