How to align data in Dataset?

Hello All,

I got a number of columns with data, but how can I align the data to the right. I tried a lot with Alignement->Right but without any success. Default is all to the left. See example.

Dataset[
 <|"0" -> <|"n" -> 19354, "%" -> 34|>
  , "1" -> <|"n" -> 3286, "%" -> 6|>
  , "2" -> <|"n" -> 8578, "%" -> 15|>
  , "3" -> <|"n" -> 22397, "%" -> 39|>
  , "4" -> <|"n" -> 3265, "%" -> 6|>
  , "TT" -> <|"n" -> 55880, "%" -> 100|>
  |>]

Thanks,…Jos

Dataset is not used as visualization. It merely shows it visually, but it is not intended for print or export. It shows it like this such as to give you a quick overview of your data. Not to refine and customize.

You can create a similar visualization using TableForm:

nds = Normal[Normal[Normal[ds]]];
labeltop = nds[[1, 2, All, 1]]
labelleft = nds[[All, 1]]
data = nds[[All, 2, All, 2]]
TableForm[data, TableHeadings -> {labelleft, labeltop}, TableAlignments -> Right]

or using Grid:

nds = Normal[Normal[Normal[ds]]];
labeltop = nds[[1, 2, All, 1]]
labelleft = nds[[All, 1]]
data = nds[[All, 2, All, 2]]
Grid[MapThread[Prepend, {Prepend[data, labeltop], Prepend[labelleft, ""]}], Frame -> True, Dividers -> {{True, True}, {True, True}},  Alignment -> Right]

giving:

Hi Sander,

Thanks for your great support…Jos

As I am trying to practice the Query syntax, I did this alternative coding:

With[
 {displayTable = 
   Grid[Join[{Prepend[Normal@ds[1, Keys], ""]}, (* top label *)
             Join[Transpose@{Keys@#}, Values@#, 2]],
        Alignment -> Right, Dividers -> {{None, Gray}, {None, Gray}}] &},
 ds[displayTable, Values]]

Hi Gustavo,

Thanks to let me know. Regards,…Jos