[R] Display a DataFrame in a data grid

Joshua Wiley jwiley.psych at gmail.com
Mon Aug 8 19:03:39 CEST 2011


Hi Ed,

In addition to Michael's suggestion (which is probably what you want),
consider something like:

head(mtcars)
tail(mtcars)

or for just the corners, you could try a little function like this:

corner <- function(x, n = 3L, ...) {
  stopifnot(length(n) == 1L)
  if (n < 0L || n * 2 > min(dim(x))) n <- floor(min(dim(x))/2)
  x[c(1:n, (nrow(x) - n):nrow(x)), c(1:n, (ncol(x) - n):ncol(x))]
}

corner(mtcars)
corner(mtcars, n = 5)

This extracts a n x n matrix from each corner.

Cheers,

Josh

On Mon, Aug 8, 2011 at 9:52 AM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> Welcome to the dark-side!
>
> I think the View() command will do what you want. This brings up a new
> window that displays the data spreadsheet style and you can scroll wherever
> you wish. If you want to do work in your command window, the head() and
> tail() commands will be of help to you.
>
> If you are just getting started with R, I'd recommend the RStudio IDE, which
> will let you pull up variables directly by clicking on their workspace
> entry.
>
> Feel free to back get in touch if this doesn't work for you.
>
> Michael Weylandt
>
> PS - In R speak, it's data.frame -- you probably knew that already, but
> that's one of those little mistakes that can be oh so frustrating to find,
> so I thought I'd just make sure.
>
> On Mon, Aug 8, 2011 at 12:43 PM, Ed Heaton <eheaton at dasconsultants.com>wrote:
>
>> Hi, all;
>>
>>
>>
>> I'm new to R.  Have been a SAS developer for over 20 years.
>>
>>
>>
>> Whenever I create a new table - you call them dataFrame objects - or modify
>> an existing one, I like to open the table in a grid with horizontal and
>> vertical sliders so that I can scan across the table and (especially) look
>> at all four corners.  If I made a gross error, it often shows up when I
>> look
>> at the corners of the table.
>>
>>
>>
>> I just can't seem to find how to evoke such a display.  Can anybody help me
>> here?
>>
>>
>>
>> Ed
>>
>>
>>
>> Ed Heaton
>> Project Manager, Sr. SAS Developer
>> Data and Analytic Solutions, Inc.
>> 3057 Nutley Street, #602
>> Fairfax, VA 22031
>> Office: 301-520-7414
>> Fax: 703-991-8182
>>  <mailto:eheaton at dasconsultants.com> eheaton at dasconsultants.com
>>  <http://www.dasconsultants.com/> www.dasconsultants.com
>> CMMI ML-2, SBA 8(a) & SDB, WBE (WBENC), MBE (VA & MD)
>>
>>
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, ATS Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/



More information about the R-help mailing list