[R] print justify

MacQueen, Don macqueen1 at llnl.gov
Wed Mar 6 17:14:56 CET 2013


I don't know about justify as an arg to print, but the following should
qualify as a hint.

> format(c('a','aa','aaa'), justify='left')
[1] "a  " "aa " "aaa"
 
> tmp <- data.frame(a=c('a','aa','aaa'))
> print(tmp,justify='left')
    a
1   a
2  aa
3 aaa
 
 
> tmp$b <- format(c('a','aa','aaa'),justify='left')
> tmp
    a   b
1   a a  
2  aa aa 
3 aaa aaa


-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 3/6/13 8:03 AM, "Berry Boessenkool" <berryboessenkool at hotmail.com>
wrote:




Hi everyone,

I'm trying to print a table justified to the left, but it doesn't work.
Any hints?

KennArt <- data.frame(NR=c(171,172,174,175,176,177,181,411,980),
TYP=c("Körnermais",
 "Corn Cob Mix", "Zuckermais", "Mischanbau (Silo)Mais/Sonnenblumen",
 "Mais mit Bejagungsschneise in gutem landwirtschaftlichen und
ökologischen Zustand",
 "Mais mit Bejagungsschneise (Kulturpflanze)", "Hirse", "Silomais (Als
Hauptfutter)", "Sudangras"))


print(KennArt, justify="left")

still justifies to the right:

   NR              
         TYP
1 171              
  Körnermais
2 172              
Corn Cob Mix
3 174              
  Zuckermais
4 175                                                Mischanbau
(Silo)Mais/Sonnenblumen
5 176 Mais mit Bejagungsschneise in gutem landwirtschaftlichen und
ökologischen Zustand
6 177                                        Mais mit Bejagungsschneise
(Kulturpflanze)
7 181              
       Hirse
8 411                                                        Silomais (Als
Hauptfutter)
9 980              
   Sudangras



print(KennArt[2:3,], justify="left")
doesn't leftify either, so it's not the German letters' fault.

format(KennArt, justify="left")
does the job mostly, but the column names are still rightified...
This solution is fine for me now, but I'm still wondering...


sessionInfo() returns:

R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C                    LC_TIME=German_Germany.1252

attached base packages:
[1] graphics  grDevices datasets  utils     stats     methods   base

other attached packages:
[1] foreign_0.8-52     fortunes_1.5-0     BerryFunctions_1.0 evd_2.3-0
    

loaded via a namespace (and not attached):
[1] tools_2.15.1



Thanks ahead,
Berry


 		 	   		  
______________________________________________
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.



More information about the R-help mailing list