[R] beginner questions: objects and scripts

Kjetil Brinchmann Halvorsen kjetil at acelerate.com
Fri Oct 15 02:40:21 CEST 2004

Terry Mu wrote:

>I got some questions on using R,
>1. How do I check and edit definition of an object?
>for example,
>>x <- 1:100

You should'nt really redefine assignment, but something like

"<<<-" <- function(xyz4, value) {
      v <- deparse(substitute(value))
      xname <- deparse(substitute(xyz4))
      res <- value
      comment(res) <- v
      assign(xname, value=res, inherits=TRUE)

and then

 > "<<<-"(x, abs(sin(3*pi/2)))
 > x
[1] 1
 > comment(x)
[1] "abs(sin(3 * pi/2))"

You could even redefine <- to be <<<-, but don't

Probably better to use the history mechanism.


>then after a while I want to check how x is defined.
>list(x) or whatever functions I know only list its
>content, but I want to see its definition, without
>scrolling up and down, and edit it like "fixing" a
>2. How to save my work in current session as a nice
>again, I want to save objects as they are defined, not
>numbers, other than copy / paste. I tried dump(), etc.
>In another word, how do you work with R?
>R-help at stat.math.ethz.ch mailing list
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Kjetil Halvorsen.

Peace is the most effective weapon of mass construction.
               --  Mahdi Elmandjra

More information about the R-help mailing list