Christoph M. Friedrich
1999-Dec-03 12:37 UTC
[R] R as Unix-Filter and Streams for DataMining
Hi, i want to use R as a filter in a Unix-like way. So i want to start it with producerTool | R --no-save --no-restore --slave < Rscript | anotherConsumerUnixTool inside the Script i put the results to stdout, works fine, but how to read in from stdin? Its obvious that i have to source the Rscript in a different way. Any Hints? My second question is, if there is a possibility to use something like the Scheme Streams (see Abelson/Sussman "Structure and Interpretation of Computer Programs") for input of Huge Amounts of Data, that do not fit in the main memory, or to reduce the necessary amount of memory? The application i have in mind is: Generate from a training set a linear or other model and then pipe in a file with the test cases (as stream with read.table) and give the output to stdout. Is there any concept in R like this? Thanks in advance Chris -- Christoph M. Friedrich | mailto:friedrich at computer.org Gesellschaft f?r Modulfermenterbau mbH (GfM mbH) | http://www.tussy.uni-wh.de/~chris Alfred-Herrhausen Str. 44 ; D-58455 Witten, Germany -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Jens Oehlschlägel-Akiyoshi
1999-Dec-03 15:01 UTC
[R] R as Unix-Filter and Streams for DataMining
My workaround currently is:
(1) Write the path and name of your input file into a file with a *fixed*
name
use unix paths //// never windows \\\\, e.g.
d:/temp/filename.txt
(2) Call R via Batchfile
(3) In the batch file set a temporary user dir for R
set R_USER=d:/temp
(4) Have an approbriate .Profile in this temporary user dir, which defines
.First
Do *not* take other actions in .Profile except for setting options and
defining .First
.First <- function(){
# get filename
filename <- scan("d:/temp/filename.txt", what=character(0))
cat("filename is ", filename, "\n")
# make use of filename
source(filename)
# exit from R
q()
}
If you discover a simpler solution, please give me a note
Best
-----Original Message-----
From: owner-r-help at stat.math.ethz.ch
[mailto:owner-r-help at stat.math.ethz.ch]On Behalf Of Christoph M.
Friedrich
Sent: Friday, December 03, 1999 1:38 PM
To: r-help at stat.math.ethz.ch
Subject: [R] R as Unix-Filter and Streams for DataMining
Hi,
i want to use R as a filter in a Unix-like way. So i want to start it
with
producerTool | R --no-save --no-restore --slave < Rscript |
anotherConsumerUnixTool
inside the Script i put the results to stdout, works fine, but how to
read in
from stdin? Its obvious that i have to source the Rscript in a different
way. Any Hints?
My second question is, if there is a possibility to use something like
the Scheme Streams
(see Abelson/Sussman "Structure and Interpretation of Computer
Programs") for input of Huge Amounts of Data, that do not fit in the
main memory, or to reduce the necessary amount of memory? The
application
i have in mind is: Generate from a training set a linear or other model
and then
pipe in a file with the test cases (as stream with read.table) and give
the output to stdout. Is there
any concept in R like this?
Thanks in advance
Chris
--
Christoph M. Friedrich | mailto:friedrich at computer.org
Gesellschaft f?r Modulfermenterbau mbH (GfM mbH) |
http://www.tussy.uni-wh.de/~chris
Alfred-Herrhausen Str. 44 ; D-58455 Witten, Germany
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"Christoph M. Friedrich" wrote:> Hi, > i want to use R as a filter in a Unix-like way. So i want to start it > with > > producerTool | R --no-save --no-restore --slave < Rscript | > anotherConsumerUnixTool > > inside the Script i put the results to stdout, works fine, but how to > read in > from stdin? Its obvious that i have to source the Rscript in a different > way. Any Hints?Two (klugey) ideas-- - write a script which reads standard input, and reads a file, and outputs both of them to standard output. (Maybe there's a command that does this already; anyone know?) You could take this one step further and just make it a wrapper for R, which would execute any files given on the command line and then read from standard input. - put your script (or a command to load your script) into .Rprofile, which R reads and executes initially. Sorry, I don't know anything about streams. -John -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._