[R] Output and history

Duncan Temple Lang duncan at research.bell-labs.com
Wed Jul 17 13:03:20 CEST 2002


Daniel Mastropietro wrote:
> Hello,
> 
> I have the following two questions, rergarding:
> 
> (Output)
> 1) Is it possible to have the output of a command automatically displayed, 
> without explicitly requesting it after the command, and without using the 
> print() function? For example, I want to see the value of 'a'  when I write 
> for instance 'a <- rep(1,10)'.
> I tried setting the 'echo' option to TRUE but it has no effect on that.


You can use addTaskCallback() to do this.
The following function (p) is registered with the top-level 
expression evaluation mechanism and called each time an expression
is completed. The fourth argument indicates whether the result
was printed or not. So in your case, you print the object iff 
`visible' is FALSE.


> p <- function(expr, value, ok, visible) {
+   if(!visible) print(value)
+   return(TRUE)
+ }
> addTaskCallback(p)
1 
1 
> a <- 10
[1] 10
> a
[1] 10
> 1:10
 [1]  1  2  3  4  5  6  7  8  9 10
> x <- 1:10
 [1]  1  2  3  4  5  6  7  8  9 10
> 





> 
> (History)
> 2) Is there a way to selectively recall a previously typed command based on 
> the first characters of the command?
> I am thinking of something similar to this: if one types 'pl' at the prompt 
> and then preses the up arrow key, only the commands starting with 'pl' will 
> show up in the command line.
> 
> 
> Thanks
> Daniel Mastropietro
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
_______________________________________________________________

Duncan Temple Lang                duncan at research.bell-labs.com
Bell Labs, Lucent Technologies    office: (908)582-3217
700 Mountain Avenue, Room 2C-259  fax:    (908)582-3340
Murray Hill, NJ  07974-2070       
         http://cm.bell-labs.com/stat/duncan
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list