I produce a number of large arrays in Julia using a script file. Printing out the whole array is cumbersome but I'd like to check the first few rows make sense.
I know in the REPL there's printing which is limited by the screen size e.g.
julia> zeros(1000,10)
1000×10 Array{Float64,2}:
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
⋮ ⋮
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
But I can't find any print/show function in base Julia which mimics this for scripts, say only printing out the first 10 rows of an array or something like R's head
(I would have expected showcompact
to do something like this).
Is there an analogous function to R's head
in Julia or do I have to write my own.
>=1.6
:first(x, 1)
is yourhead
equivalent andlast(x, 1)
yourtail
equivalent. See: docs.julialang.org/en/v1/base/collections/#Base.first – Detoxicate