Hi,

I just started out with Julia coming from R and have two questions 
regarding the DataFrames package:


*Is there a way to format the output of a DataFrame so that numbers are 
aligned by the last digit (Integer) or decimal point (i.e. Double) ?*


for comparison:

## R Code

> head(anscombe)
  x1 x2 x3 x4   y1   y2    y3   y4
1 10 10 10  8 8.04 9.14  7.46 6.58
2  8  8  8  8 6.95 8.14  6.77 5.76
3 13 13 13  8 7.58 8.74 12.74 7.71
4  9  9  9  8 8.81 8.77  7.11 8.84
5 11 11 11  8 8.33 9.26  7.81 8.47
6 14 14 14  8 9.96 8.10  8.84 7.04


## Julia Code

julia> using DataFrames, RDataSets
julia> anscombe = dataset("datasets", "anscombe");
julia> head(anscombe)
6x8 DataFrame
| Row | X1 | X2 | X3 | X4 | Y1   | Y2   | Y3    | Y4   |
|-----|----|----|----|----|------|------|-------|------|
| 1   | 10 | 10 | 10 | 8  | 8.04 | 9.14 | 7.46  | 6.58 |
| 2   | 8  | 8  | 8  | 8  | 6.95 | 8.14 | 6.77  | 5.76 |
| 3   | 13 | 13 | 13 | 8  | 7.58 | 8.74 | 12.74 | 7.71 |
| 4   | 9  | 9  | 9  | 8  | 8.81 | 8.77 | 7.11  | 8.84 |
| 5   | 11 | 11 | 11 | 8  | 8.33 | 9.26 | 7.81  | 8.47 |
| 6   | 14 | 14 | 14 | 8  | 9.96 | 8.1  | 8.84  | 7.04 |


I would really like to match R's formatting as it's more readable for me. 


*Is there a possibility to specify the number of displayed digits after the 
decimal points for the output of an array?*

julia> arr = [ 1.2334 2345.234;  2123.290 8349.2 ]
2x2 Array{Float64,2}:
    1.2334  2345.23
 2123.29    8349.2

The alignment here is better, but I lose last digit of the upper right 
value. The value on the upper left has all decimal places (4).



Thank you,

Peter

Reply via email to