[R] automated data processing

From: <mw-u2_at_gmx.de>
Date: Wed 14 Jun 2006 - 05:34:40 EST

I have many files (0.4.dat, 0.5.dat, ...) of which I would like to calculate mean value and variance and save the output in a new file where each line shouldlook like: "0.4 mean(0.4.dat) var(0.4.dat)" and so on. Right now I got a a simple script that makes me unhappy:

  1. I run it by "R --no-save < script.r > out.dat" unfortunately out.dat has all the original commands in it and a "[1]" infront of every output
  2. I would love to have a variable running through 0.4, 0.5, ... naming the datafile to process and the first column in the output.

My script looks like:

data <- read.table("0.4.dat"); E <- data$V1[1000:length(data$V1)]; c(0.4, mean(E), var(E));
data <- read.table("0.5.dat"); E <- data$V1[1000:length(data$V1)]; c(0.5, mean(E), var(E));

And that would be its output:

#[1]     0.400 -1134.402  5700.966

#> data <- read.table("0.5.dat"); E <- data$V1[1000:length(data$V1)];
#> c(0.5, mean(E), var(E));

#[1] 0.500 -1787.232 2973.692



Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Jun 14 06:47:52 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 14 Jun 2006 - 08:12:08 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.