Sorry, I've been feeling under the weather since yesterday. Anyways:
With vd in your path

printf %"d\n" 1 2 3 4 5 | vd

then
1. Shift+C: brings you to the 'columns sheet'
2. s: selects the 'text' column
3. g%: switches the 'text' column to float type
4. q: brings you back to the row sheet
5. z+: asks you for an aggregator name, type 'avg' and ENTER

You get the mean on the status line.

Now, if you configure Visidata with this in a '.visidatarc' file where vd
can find it:

#--------------------------------------------------------------------------
import sys
sys.path.append('/home/raoul/Desktop/j903/addons/api/python3')  # change
path as appropriate
import numpy as np
from visidata import vd

jbase.init(False)

def j_mean(vals):
    jbase.set('temp', np.array(vals))
    e = jbase.do('var=:9')
    r = jbase.get('var')
    return e

vd.aggregator('j-mean', j_mean, 'get mean from J',type=float)
BaseSheet.addCommand('0', 'hello-world', 'status("Hello!")')
#------------------------------------------------------------------------

Following the same sequence as for 'avg', you can now type 'j-mean', which
triggers the issue.
For testing, if you press '0', 'Hello!' should appear on the status line.

Thanks to anyone who tries this!
Cheers,
Raoul

On Fri, Jul 2, 2021 at 6:36 PM Brian Schott <schott.br...@gmail.com> wrote:

> Eric,
> Thanks, that works for me.
> Btw, I edited line 11 of jbase.py as follows.
>
> jbase.dor('ghi')       # print array   Brian removed 'j' in 'jdor'
>
> Raoul,
>
> I have installed visidata using the  instructions at github.
> But I don't understand how to follow the further *Usage* instructions at
> github below.
> Could you please provide more information for usage?
>
> $ vd <input>
> $ <command> | vd
>
>
>
> On Fri, Jul 2, 2021 at 11:40 AM Eric Iverson <eric.b.iver...@gmail.com>
> wrote:
>
> > The file /Users/brian/j64-807/bin/libj.so is for linux. For osx you need:
> > /Users/brian/j64-807/bin/libj.dylib
> >
> > You could try finding where that is set in the addon and editing as
> > appropriate.
> >
> >
> --
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to