[R] viewing data in something similar to 'R Data Editor'

D McArthur dmca at ucla.edu
Mon Aug 4 18:00:03 CEST 2008


With the R prompt still active, data may be cleanly viewed (not 
edited) in a separate window by a simplification of function xless in 
Hmisc by Frank Harrell:

look. <- function (x, ...,
      title = substring(deparse(substitute(x)), 1, 20))
     {
      page(x, method = "print", title = title,options=(width=150))
         invisible()
     }

Names alone can be viewed separately as well:

names.
function (x, ...,
      title = c(substring(deparse(substitute(x)), 1, 20)))
     {       title=paste(title," ...NAMES")
      page(names(x), method = "print", title = title,options=(width=150))
         invisible()
     }

Both functions work in Windows XP and Mac OS X Leopard under R 2.7.1 
and earlier.

-- D L McArthur, UCLA Department of Neurosurgery

 >
 > On Aug 1, 2008, at 7:29 PM, Rachel Schwartz wrote:
 >
 >> Hi,
 >>
 >> I would like to view matrices I am working with in a clean, easy to read,
 >> separate window.
 >>
 >> A friend showed me how to do something like I want  with edit(). I can
 >> view
 >> the matrix in the 'R Data Editor':
 >>
 >> For a sample matrix:
 >>
 >>> mat=matrix(1:15,ncol=3)
 >>> mat
 >>     [,1] [,2] [,3]
 >> [1,]    1    6   11
 >> [2,]    2    7   12
 >> [3,]    3    8   13
 >> [4,]    4    9   14
 >> [5,]    5   10   15
 >>
 >>
 >>> look=function(x) invisible(edit(x))
 >>> look(mat)
 >>
 >> That opens the 'R Data Editor' with mat loaded.
 >>
 >>
 >> But I am not able to do any other actions in R while this 'R Data
 >> Editor' is
 >> open. I want to keep this open while
 >> I do other work.
 >>
 >> Is there a way to view my data in something like the 'R Data Editor' that
 >> still allows me to do work at the same time?
 >> I am looking for something other than  str(), head(), and tail() which
 >> just
 >> allow me a quick peak at the object. I do not
 >> want to edit the object in the table, but be able to watch the object
 >> change
 >> while I run anything that would manipulate it.
 >>
 >> Thank you for your help.
 >>
 >> Best,
 >> Rachel Schwartz
 >> Graduate Student Researcher
 >> UCSD; Scripps Institution of Oceanography



More information about the R-help mailing list