Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: How can I disable truncation of listing of package functions?

Tags:

r

How can I list all of the results that used to occur when typing packageName<tab>, i.e. the full list offered via auto-completion? In R 2.15.0, I get the following for Matrix::<tab>:

> library(Matrix)
> Matrix::
Matrix::.__C__abIndex               Matrix::.__C__atomicVector          Matrix::.__C__BunchKaufman          Matrix::.__C__CHMfactor             Matrix::.__C__CHMsimpl              
Matrix::.__C__CHMsuper              Matrix::.__C__Cholesky              Matrix::.__C__CholeskyFactorization Matrix::.__C__compMatrix            Matrix::.__C__corMatrix             
Matrix::.__C__CsparseMatrix         Matrix::.__C__dCHMsimpl             Matrix::.__C__dCHMsuper             Matrix::.__C__ddenseMatrix          Matrix::.__C__ddiMatrix             
Matrix::.__C__denseLU               Matrix::.__C__denseMatrix           Matrix::.__C__dgCMatrix             Matrix::.__C__dgeMatrix             Matrix::.__C__dgRMatrix             
Matrix::.__C__dgTMatrix             Matrix::.__C__diagonalMatrix        Matrix::.__C__dMatrix               Matrix::.__C__dpoMatrix             Matrix::.__C__dppMatrix             
Matrix::.__C__dsCMatrix             Matrix::.__C__dsparseMatrix         Matrix::.__C__dsparseVector         Matrix::.__C__dspMatrix             Matrix::.__C__dsRMatrix             
Matrix::.__C__dsTMatrix             Matrix::.__C__dsyMatrix             Matrix::.__C__dtCMatrix             Matrix::.__C__dtpMatrix             Matrix::.__C__dtrMatrix             
Matrix::.__C__dtRMatrix             Matrix::.__C__dtTMatrix             Matrix::.__C__generalMatrix         Matrix::.__C__iMatrix               Matrix::.__C__index                 
Matrix::.__C__isparseVector         Matrix::.__C__ldenseMatrix          Matrix::.__C__ldiMatrix             Matrix::.__C__lgCMatrix             Matrix::.__C__lgeMatrix             
Matrix::.__C__lgRMatrix             Matrix::.__C__lgTMatrix             Matrix::.__C__lMatrix               Matrix::.__C__lsCMatrix             Matrix::.__C__lsparseMatrix         

[...truncated]

That [...truncated] message is irritating and I want to produce the full listing. Which option/flag/knob/configuration/incantation do I need to invoke in order to avoid the truncation? I have this impression that I used to see the full list, but not anymore - perhaps that was on a different OS (e.g. Linux).

I know that ls("package:Matrix") is one useful approach, but it is not the same as setting an option, and the list is different.

like image 803
Iterator Avatar asked May 06 '12 00:05

Iterator


1 Answers

Unfortunately, on Windows, it looks like this behavior is hard-wired into the C code used to construct the console. So the answer seems to be that "no, you can't disable it" (at least not without modifying the sources and then recompiling R from scratch).

Here are the relevant lines from $RHOME/src/gnuwin32/console.c:

909 static void performCompletion(control c)
910 {
911    ConsoleData p = getdata(c);
912    int i, alen, alen2, max_show = 10, cursor_position = p->c - prompt_wid;
    ...
    ...
1001      if (alen > max_show)
1002      consolewrites(c, "\n[...truncated]\n");

You are correct that on some other platforms, all of the results are printed out. (I often use Emacs, for instance, and it pops all results of tab completion up in a separate buffer).

As an interesting side note, rcompgen, the backend that actually performs the tab-completion (as opposed to printing results to the console) does always find all completions. It's just that Windows doesn't then print them out for us to see.

You can verify that this happens even on Windows by typing:

library(Matrix)
Matrix::
## Then type <TAB> <TAB>
## Then type <RET>
rc.status()      ## Careful not to use tab-completion to complete rc.status !
matches <- rc.status()$comps
length(matches)  # -> 288
matches          # -> lots of symbols starting with 'Matrix::'

For more details about about the backend, and the functions and options that control its behavior, see ?rcompgen.

like image 172
Josh O'Brien Avatar answered Oct 20 '22 20:10

Josh O'Brien