Skip to content
Back to formatted view

Raw Message

Message-ID: <16443.5204.413726.233082@gargle.gargle.HOWL>
Date: 2004-02-24T09:07:32Z
From: Martin Maechler
Subject: would be nice ...
In-Reply-To: <D4389EED-66A6-11D8-8997-000A95A67E82@stat.ucla.edu>

>>>>> "Jan" == Jan de Leeuw <deleeuw at stat.ucla.edu>
>>>>>     on Tue, 24 Feb 2004 00:52:51 -0800 writes:

    Jan> if R had something like
    >> python -c "print(sum([1,2,3]));print(3*2)"
    Jan> 6 6

    Jan> but I guess the only way to do this is by writing the
    Jan> string to a tmp file and then doing something like "R
    Jan> CMD BATCH --quiet" on the tmp file

Well, a bit better (with a shell prompt "%") is

    % echo "print(sum(c(1,2,3)));print(3*2)" | R --quiet --vanilla

    > print(sum(c(1,2,3)));print(3*2)
    [1] 6
    [1] 6
    > 

or (slightly nicer)

    % echo "sum(c(1,2,3)); 3*2" | R --quiet --vanilla
    > sum(c(1,2,3)); 3*2
    [1] 6
    [1] 6
    > 

but it still echoes the input by default

    Jan> I would like to use this for an R service, which allows
    Jan> you to select any string in any application and replace
    Jan> it by its R evaluation