[R] [semi-OT] Using fortune() in an email signature
Dirk Eddelbuettel
edd at debian.org
Wed Sep 1 23:18:27 CEST 2010
On 1 September 2010 at 15:49, Stuart Luppescu wrote:
| Hello, As you can see from my signature in this message, I use the R
| fortune function to generate a fortune, which is then fed to the
| signature program, which constructs a named pipe containing the
| fortune-bearing sig, which is then included in mail messages. The
| problem is that it's got extraneous junk in it and I can't figure out
| how to get rid of it. This is the command that generates the fortune:
|
| /usr/bin/R --no-save --no-restore -q < /home/sl70/print-fortune.R
| (where print-fortune.R is just
| library(fortunes)
| fortune()
| )
|
| This produces this:
| > library(fortunes)
| > fortune()
|
| Michael Watson: Hopefully this one isn't in the manual or I am about to get shot :-S
| Peter Dalgaard: *Kapow*...
| -- Michael Watson and Peter Dalgaard (question on axis())
| R-help (February 2006)
|
| >
|
| I would like to remove the first two lines and the last line, so I
| changed the command to this:
| /usr/bin/R --no-save --no-restore < /home/sl70/print-fortune.R |tail \
| -n +23 | head -n -2 2> /dev/null
|
| That give the desired result when I run it at the command line, but when
| I feed it to the signature program, I get this message:
There are scripting front-ends to R for these tasks. A few years ago Jeff and
I released 'r' (aka littler), R Core followed up with Rscript a few months
later. I still use r more.
In r / littler, all calls to library() are wrapped in suppressMessages()
because I too hate that echo from library loads. So here is what you could do:
edd at max:~$ r --package=fortunes --eval="print(fortune())"
Ah, so that's why my report of a bug in the RCheapViagra package didn't get through....
-- Barry Rowlingson (after Peter Dalgaard announced a new spam filter for R-bugs)
R-devel (January 2004)
edd at max:~$ r --package=fortunes --eval="print(fortune())"
I use R. My company benefits from it. My clients benefit from it.
...and I sleep just fine (when I do sleep)... :-)
-- Marc Schwartz, Medanalytics (about the 'costs' of free software)
R-help (June 2004)
edd at max:~$ r -lfortunes -e"print(fortune())" # shorter form
Soon, they'll be speaking R on the subway.
-- Michael Rennie (giving 'Kudos to the R support team')
R-help (July 2004)
edd at max:~$
Doing the same with Rscript is left as an exercise....
Cheers, Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the R-help
mailing list