Skip to content
Prev 299508 / 398503 Next

Extracting arithmetic mean for specific values from multiple .txt-files

Hello,

Your data example has dots in the column of interess. If those values 
are ntegers, this might do it.


fun <- function(x){
	dat <- read.table(x, skip=14)
	H <- as.numeric(gsub("\\.", "", dat[, 8]))
	mean(H)
}

sapply(list.files(pattern="XYZ.*\\.txt"), fun)

Now do what you want with the result, for instance, write.table().

Hope this helps.

Rui Barradas

Em 09-07-2012 12:20, vimmster escreveu:

Thread (16 messages)

vimmster Extracting arithmetic mean for specific values from multiple .txt-files Jul 8 jim holtman Extracting arithmetic mean for specific values from multiple .txt-files Jul 8 vimmster Extracting arithmetic mean for specific values from multiple .txt-files Jul 9 Rui Barradas Extracting arithmetic mean for specific values from multiple .txt-files Jul 9 vimmster Extracting arithmetic mean for specific values from multiple .txt-files Jul 9 jim holtman Extracting arithmetic mean for specific values from multiple .txt-files Jul 9 Rui Barradas Extracting arithmetic mean for specific values from multiple .txt-files Jul 9 vimmster Extracting arithmetic mean for specific values from multiple .txt-files Jul 10 Rui Barradas Extracting arithmetic mean for specific values from multiple .txt-files Jul 10 vimmster Extracting arithmetic mean for specific values from multiple .txt-files Jul 10 Rui Barradas Extracting arithmetic mean for specific values from multiple .txt-files Jul 10 vimmster Extracting arithmetic mean for specific values from multiple .txt-files Jul 10 vimmster Extracting arithmetic mean for specific values from multiple .txt-files Jul 10 Rui Barradas Extracting arithmetic mean for specific values from multiple .txt-files Jul 11 vimmster Extracting arithmetic mean for specific values from multiple .txt-files Jul 11 vimmster Extracting arithmetic mean for specific values from multiple .txt-files Jul 12