2017-11-30 6 views
0

xtableknitrに使用してテーブルを作成していますが、現在のところ、すべてのxtable列は簡単で再現性があります。データフレームの列タイプに基づいてxtable列を整列するR

しかし、データフレーム列(num、chr、intなど)内のデータのタイプに応じて、xtable列を揃える方法があるかどうかは疑問です文字を整列させる。

ありがとうございます!

答えて

2

私はそれが既にケースだと思う:xtable例ページから

precip 
      Mobile    Juneau    Phoenix   Little Rock   Los Angeles   Sacramento  San Francisco 
       67.0    54.7     7.0    48.5    14.0    17.2    20.7 
      Denver   Hartford   Wilmington   Washington  Jacksonville    Miami    Atlanta 
       13.0    43.4    40.2    38.9    54.5    59.8    48.3 
      Honolulu    Boise    Chicago    Peoria  Indianapolis   Des Moines    Wichita 
       22.9    11.5    34.4    35.1    38.7    30.8    30.6 
     Louisville   New Orleans   Portland   Baltimore    Boston    Detroit Sault Ste. Marie 
       43.1    56.8    40.8    41.8    42.5    31.0    31.7 
      Duluth Minneapolis/St Paul    Jackson   Kansas City   St Louis   Great Falls    Omaha 
       30.2    25.9    49.2    37.0    35.9    15.0    30.2 
       Reno    Concord  Atlantic City   Albuquerque    Albany    Buffalo   New York 
       7.2    36.2    45.5     7.8    33.4    36.1    40.2 
      Charlotte    Raleigh    Bismark   Cincinnati   Cleveland   Columbus  Oklahoma City 
       42.7    42.5    16.2    39.0    35.0    37.0    31.4 
      Portland  Philadelphia   Pittsburg   Providence   Columbia   Sioux Falls    Memphis 
       37.6    39.9    36.2    42.8    46.4    24.7    49.1 
      Nashville    Dallas    El Paso    Houston  Salt Lake City   Burlington    Norfolk 
       46.0    35.9     7.8    48.2    15.2    32.5    44.7 
      Richmond  Seattle Tacoma    Spokane   Charleston   Milwaukee   Cheyenne   San Juan 
       42.6    38.8    17.4    40.8    29.1    14.6    59.2 
> xalign(names(precip))# a character vector 
[1] "l" 
> xalign(precip)# a numeric 
[1] "r 
関連する問題