Paul Menzel
2011-Dec-12 10:26 UTC
[R] littler: Use for batch processing of data sets: How to pass filename?
Dear R folks,
I have several data sets I want to process automatically using R. I
found littler [1] and thought this will do the trick.
1. Read in data file to a data frame using `scan()`.
2. Do linear regression.
3. Write the data and the coefficients back to a file.
#!/usr/bin/env r
if (is.null(argv) | length(argv)!=1) {
cat("Usage: auswertung.r datafile \n")
q()
}
filename <- as.character(argv[1])
d = data.frame(x=scan("/tmp/data"))
write(sum(d$x), "/tmp/data.result", ncolumns=1)
Could someone help me how I can substitude `/tmp/data` with the value
stored in `filename`? I do not get it to work using `do.Call` or
`paste()`.
Thanks,
Paul
[1] http://code.google.com/p/littler/
-------------- next part --------------
1
2
3
4
-------------- next part --------------
#!/usr/bin/env r
if (is.null(argv) | length(argv)!=1) {
cat("Usage: auswertung.r datafile \n")
q()
}
filename <- as.character(argv[1])
d = data.frame(x=scan("/tmp/data"))
write(sum(d$x), "/tmp/data.result", ncolumns=1)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20111212/3bbae841/attachment.bin>
R. Michael Weylandt <michael.weylandt@gmail.com>
2011-Dec-12 14:41 UTC
[R] littler: Use for batch processing of data sets: How to pass filename?
Why can't you just replace "temp/data" with filename (no quotes)? I'm not sure I get the question... Michael On Dec 12, 2011, at 5:26 AM, Paul Menzel <paulepanter at users.sourceforge.net> wrote:> Dear R folks, > > > I have several data sets I want to process automatically using R. I > found littler [1] and thought this will do the trick. > > 1. Read in data file to a data frame using `scan()`. > 2. Do linear regression. > 3. Write the data and the coefficients back to a file. > > #!/usr/bin/env r > > if (is.null(argv) | length(argv)!=1) { > > cat("Usage: auswertung.r datafile \n") > q() > > } > > filename <- as.character(argv[1]) > > d = data.frame(x=scan("/tmp/data")) > write(sum(d$x), "/tmp/data.result", ncolumns=1) > > Could someone help me how I can substitude `/tmp/data` with the value > stored in `filename`? I do not get it to work using `do.Call` or > `paste()`. > > > Thanks, > > Paul > > > [1] http://code.google.com/p/littler/ > <data> > <auswertung.r> > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.