Hello, Many thanks to you all for the prompt reply. Thanks for sharing.
On Saturday, 12 Jun 2021 at 09:53, Jeff Newmiller wrote: > Can't say this appeals to me, but sprintf would make a difference: > > apply( > mat,1, > function(x) { > x[is.na(x)] <-"" > cat(paste(sprintf("%16s",x)),"\n") > }) @Jeff your solution seems to suit my need the most Just reducing the field width to 8 and added a minus sign for left justification. apply( mat,1, function(x) { x[is.na(x)] <-"" cat(paste(sprintf("-%8s",x)),"\n") }) On Saturday, 12 Jun 2021 at 20:04, Greg Minshall wrote: > Jeremie, > > i'm not totally sure i understand your desire. but, does this help? > mx <- max(nchar(mat), na.rm=TRUE) > apply( > mat,1, > function(x) { > x[is.na(x)] <-"" > cat(sprintf("%*s", mx, x), "\n") > }) @Greg many thanks for your input, the mx variable will certainly come in handy. On Saturday, 12 Jun 2021 at 14:00, Avi Gross via R-help wrote: > mat <- sprintf("%-*s", col_width, mat) @Avi many thanks for the left justification. It did encourage me to read the sprintf help more carefully. With the solution above, I get a razor thin front-end. To map columns name interactively with barely 200 lines of code, and I can trigger the debugger at anytime to inspect the full table. Very powerful. Best regards, Jeremie ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.