summary: I'd like a tool to use within an R session (better yet an ESS
buffer) that would
* (minimally) allow me to page (? la `less`) a large sparse matrix
* (preferably) page row-wise (i.e., show all values for row=1 before
proceeding to row=2)
details:
Apologies if this is a FAQ, but I didn't find anything in `help.print`
or google="R pager". (If there's a better way to search for
answers to
this sort of question, please lemme know.)
I'm new to R, though not to computing. I've been using linux for many
years (and before that cygwin) and am very fond of `less` for paging
output. I'm using R package=ncdf to load parts of a large netCDF file,
e.g.,
> > var_01 <- get.var.ncdf(filedata, var, start=c(1,1,1,1),
count=c(459,299,1,1))
> > class(var_01)
> [1] "matrix"
> > dim(var_01)
> [1] 459 299
I'd like to be able to view values directly (more on why and how
follows), but when I do
> > print(var_01)
I get output like
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
> [1,] NA NA NA NA NA NA NA NA NA NA NA NA
...> [334,] NA NA NA NA NA NA NA NA NA NA NA NA
> [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
> [1,] NA NA NA NA NA NA NA NA NA NA
...> [196,] NA NA NA NA NA 5.36 6.11 6.87 9.44 NA
...> [210,] 0.19 0.80 2.01 3.93 NA NA NA NA NA NA
...> [334,] NA NA NA NA NA NA NA NA NA NA
and so on ... for a very long time. I can then scroll up the buffer
(I'm running R inside of ESS
http://ess.r-project.org/Manual/ess.html
) but it's a PITA, since `print`
- prints the whole 459x299 mx all at once. I'd much prefer to be able to
control the flow of output, ? la `less`, so that's my major ask:
what to use for an R pager (whether in a console or an ESS buffer)?
- is printing hundreds of rows at a time. `print` is correctly sensing
the width of the "console" (actually an emacs frame) and only
printing
as many columns as will fit in that width (see example above).
However, for some reason `print` is also choosing to format output by
a row height row.h=334 (not sure how it chose 334), which is *waaay*
more rows than I can handle at once. I'd much prefer "row-wise"
output, i.e., one row at a time, e.g.,
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] ...
[,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,] ...
...
[,291] [,292] [,293] [,294] [,295] [,296] [,297] [,298] [,299]
[1,] ...
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[2,] ...
For extra credit, I'd prefer a tool that sensed when a row was all NA
and "didn't waste my time." E.g., if all the cells in the first
row
contained value=NA, but the second row contained non-NA values, the
output would be like
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] NA...
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[2,] ...
[,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[2,] ...
...
[,291] [,292] [,293] [,294] [,295] [,296] [,297] [,298] [,299]
[2,] ...
But that's gravy: all I really want is a pager, and preferably one
that will allow me to output row-wise. Is there such a tool for R?
or ESS?
TIA, Tom Roche <Tom_Roche at pobox.com>