[R] most stable way to output text layout
    Jeremie Juste 
    jerem|eju@te @end|ng |rom gm@||@com
       
    Sat Jun 12 18:24:51 CEST 2021
    
    
  
Hello,
I'm trying to print a razor thin front-end using just text matrices and
the command prompt.
I admit that it is a bit crazy, it seems to do the job and is very quick
to implement...  Except that I don't know of to fix the layout.
I'm just seeking to map column names to a standard domain in an
interactive way.
For instance, at one iteration, the following matrix is produced:
mat <- structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, "a", "b", "c", "d", "e", "f", "g", 
"h", "i", "j", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, "n_missing:", "n_unique:", "freq:", 
NA, NA, NA, NA, NA, NA, NA, "0", "10", NA, "a", "1", NA, NA, 
NA, NA, NA, NA, NA, NA, "b", "1", NA, NA, "best match: [1]:", 
NA, NA, NA, NA, NA, "c", "1", NA, NA, "foo", NA, NA, NA, NA, 
NA, "d", "1", NA, NA, NA, NA, NA), .Dim = c(10L, 10L))
which I represent in the console using the following command
    apply(
      mat,1,
      function(x) {
        x[is.na(x)] <-""
        cat(x,"\n")
      })
Do you have any suggestion for how can I have better control on the
print layout of the  matrix so that I can fix the width of each cell?
Best regards,
-- 
Jeremie Juste
    
    
More information about the R-help
mailing list