Dear all,
I wrote a simple script in order to put together some functions and method
to be executed on various files
I am trying to have to possibility to call the script changing few
parameters in order to use the different files.
I succeeded partly using the function method.
However in my script I call the sink() function in order to output the
results to a .txt file. When using the function the file is empty, when
running the script manually the file is fine. How can I solve that?
Is there any other way to run a R script on different files with different
names?

Thank you very much in advance

Laura

=============================
EXAMPLE OF CODE
=============================
km = function(a,o) {

fld <- system.file("G:/ALRPC/JRC/IMG/", package="rgdal")
filename = as.name(paste (a, "-", o, sep=""))
file <- read.table(paste("R_out/", filename, ".txt", sep=""))

obj <- kmenas(file, 5)

sink(paste("R_out/res", filename, ".txt", sep=""))
"Kluster centers"
obj$centers
"Within size for clusters"
obj$withinss
"Cluster size"
obj$size
sink()
}

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to