The DataFrames package still gives me a hard time (coming from R). Two issues I 
run into most often:

1. Below error message, not sure what I'm doing wrong here. Do I need to use 
join()? Or am I missing a use of comprehension? In ModelFrames the '.' is not 
allowed, so I would like to be able to say something like lm(Y ~ X, df). But 
maybe this is to R-ish?

2. Printing of a DataFrame. A small DataFrame (< 7 columns?) is printed in the 
REPL (like df below), but a larger DataFrame seems to give me the structure of 
the DataFrame. Can I influence that number of 7?

Rob J. Goedman
[email protected]

julia> versioninfo()
Julia Version 0.3.0-prerelease+3191
Commit 03d91ba* (2014-05-16 15:41 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.2.0)
  CPU: Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)
  LAPACK: libopenblas
  LIBM: libm

julia> X1
3x2 Array{Int64,2}:
 1  4
 2  5
 3  6

julia> Y1
3-element Array{Int64,1}:
 1
 3
 5

julia> DataFrame(X=X1[:, 1], Y=Y1)
3x2 DataFrame
|-------|---|---|
| Row # | X | Y |
| 1     | 1 | 1 |
| 2     | 2 | 3 |
| 3     | 3 | 5 |

julia> df = DataFrame(X=X1[:, 2], Y=Y1)
3x2 DataFrame
|-------|---|---|
| Row # | X | Y |
| 1     | 4 | 1 |
| 2     | 5 | 3 |
| 3     | 6 | 5 |

julia> DataFrame(X=X1[:, 1:2], Y=Y1)
ERROR: New columns must have the same length as old columns
 in insert_single_column! at 
/Users/rob/.julia/v0.3/DataFrames/src/dataframe/dataframe.jl:383
 in setindex! at 
/Users/rob/.julia/v0.3/DataFrames/src/dataframe/dataframe.jl:444
 in DataFrame at /Users/rob/.julia/v0.3/DataFrames/src/dataframe/dataframe.jl:63

julia> X1[:, 1:2]
3x2 Array{Int64,2}:
 1  4
 2  5
 3  6



julia> df
3x2 DataFrame
|-------|---|---|
| Row # | X | Y |
| 1     | 4 | 1 |
| 2     | 5 | 3 |
| 3     | 6 | 5 |

julia> samples_df
1000x16 DataFrame
|-------|---------------|---------|---------|
| Col # | Name          | Eltype  | Missing |
| 1     | lp__          | Float64 | 0       |
| 2     | accept_stat__ | Float64 | 0       |
| 3     | stepsize__    | Float64 | 0       |
| 4     | treedepth__   | Int64   | 0       |
| 5     | n_leapfrog__  | Int64   | 0       |
| 6     | n_divergent__ | Int64   | 0       |
| 7     | mu            | Float64 | 0       |
| 8     | theta_1       | Float64 | 0       |
| 9     | theta_2       | Float64 | 0       |
| 10    | theta_3       | Float64 | 0       |
| 11    | theta_4       | Float64 | 0       |
| 12    | theta_5       | Float64 | 0       |
| 13    | theta_6       | Float64 | 0       |
| 14    | theta_7       | Float64 | 0       |
| 15    | theta_8       | Float64 | 0       |
| 16    | tau           | Float64 | 0       |

julia> samples_df[:, 7:12]
1000x6 DataFrame
|-------|----------|----------|---------|----------|----------|---------|
| Row # | mu       | theta_1  | theta_2 | theta_3  | theta_4  | theta_5 |
| 1     | 10.4332  | 5.37291  | 19.7482 | 3.56708  | 7.27914  | 5.88818 |
| 2     | 8.22581  | 14.2675  | 12.141  | 8.32665  | 2.95288  | 5.34375 |
| 3     | 10.9068  | 7.43814  | 10.1394 | 7.34402  | 6.14595  | 6.53342 |
| 4     | 10.9068  | 7.43814  | 10.1394 | 7.34402  | 6.14595  | 6.53342 |
| 5     | 9.61714  | 8.90304  | 10.2919 | 8.40993  | 7.06141  | 6.35706 |
| 6     | 7.46585  | 12.2761  | 7.64693 | 4.87427  | 8.23898  | 6.50898 |
| 7     | 12.3858  | 6.32497  | 8.23373 | 12.6327  | 11.2788  | 5.70445 |
| 8     | 8.66217  | 10.2486  | 7.02425 | 15.3532  | 15.0876  | 5.2819  |
| 9     | 13.2488  | 21.4967  | 9.04809 | 3.62114  | -5.58207 | 6.72995 |
⋮
| 991   | 6.44634  | -7.45131 | 13.8173 | 0.726336 | 5.32585  | 7.74152 |
| 992   | -1.84407 | 5.74692  | 3.77242 | 7.83245  | 11.0352  | 2.81801 |
| 993   | 3.54546  | 7.49026  | 11.8291 | 5.5823   | 11.2318  | 5.04784 |
| 994   | 21.6616  | 23.7753  | 1.0125  | 8.47316  | 0.786987 | 7.47116 |
| 995   | 10.0226  | 12.4223  | 11.7201 | 16.0979  | 33.8617  | 2.83627 |
| 996   | 15.299   | 17.4176  | 13.2271 | 11.5311  | -2.48596 | 8.27366 |
| 997   | 16.3412  | 20.98    | 15.723  | 2.40238  | 29.9986  | 8.09409 |
| 998   | 8.42056  | 7.86757  | 11.8463 | 13.2561  | 10.2436  | 7.41587 |
| 999   | 8.52441  | 10.568   | 16.061  | 11.2477  | 12.1242  | 9.03829 |
| 1000  | 11.2382  | 9.76319  | 12.3402 | 3.54328  | 10.975   | 5.75154 |

julia> samples_df[:, 7:13]
1000x7 DataFrame
|-------|---------|---------|---------|
| Col # | Name    | Eltype  | Missing |
| 1     | mu      | Float64 | 0       |
| 2     | theta_1 | Float64 | 0       |
| 3     | theta_2 | Float64 | 0       |
| 4     | theta_3 | Float64 | 0       |
| 5     | theta_4 | Float64 | 0       |
| 6     | theta_5 | Float64 | 0       |
| 7     | theta_6 | Float64 | 0       |


Reply via email to