I don't know if this also works with DataArrays, but if it would be a 
"normal" Array you could use ``unique`` on the first column to figure out 
how many R values you have. Then you can reshape the last column 
accordingly. Something like

Rvalues = unique(data[:,1])
reshape(data[:,3], div(size(data,1),length(Rvalues)), length(Rvalues))


If you use unique also for the Z column, you can extract the limits of the 
axes as well.

Best, 
Alex


On Monday, 5 May 2014 11:14:50 UTC+2, Tomas Lycken wrote:
>
> A c++ program of mine dumps some data in a loop somewhat similar to this:
>
>     f << "R Z diagnostic" << std::endl;
>
>     for (double R = 0.0; R <= 1.0; R += .1) {
>         for (double Z = 0.0; Z <= 1.0; Z += .1) {
>             f << R << " " << Z << " " << some_diagnostic(R, Z) << 
> std::endl;
>         }
>     }
>
> resulting in a file that can look like this at the top:
>
> R Z diagnostic
> 0.0 0.0 0.0
> 0.0 0.1 5.2
> 0.0 0.2 5.8
> ...
> 0.0 0.9 4.7
> 0.0 1.0 4.3
> 0.1 0.0 0.2
> 0.1 0.1 1.5
> ...
> etc...
>
> Now, I'd like to reshape this somehow so that I can plot the diagnostic as 
> a function of both R and Z, using e.g. Winston.imagesc. However, I don't 
> want to make assumptions on the number of steps taken in either direction - 
> the script should "just work" even if I change the evaluation points inside 
> the c++ program. I tried using some combinations of `diff` and `find` to 
> figure out the number of rows and columns I would need in a matrix, but 
> usually ended up with errors such as "no method find(DataArray{Float64,1})".
>
> I did find this page on the 
> documentation<http://juliastats.github.io/DataFrames.jl/reshaping_and_pivoting.html>
>  which 
> suggests to me that this shouldn't be so difficult, but I can't wrap my 
> head around how to do it. Help, please? =)
>
> // T
>

Reply via email to