[R] automating a script to read a file
Petr Savicky
savicky at cs.cas.cz
Mon Apr 23 22:42:13 CEST 2012
On Mon, Apr 23, 2012 at 04:02:45PM -0400, Steve_Friedman at nps.gov wrote:
>
> Hi,
>
>
> The following script (which I did not develop) is used to calculate and
> plot a skewed normal curve. The script currently requires the user to
> input six parameters, rather than reading these directly from a file.
>
> I've been spinning wheels here, trying to figure out how to modify the
> script to automate it. I have four data sets, each in excess of 300
> records that I need to process.
>
> My initial thoughts were to use the lapply and use a pdf graphic device to
> capture the plots to do this, but my R programming skills are too limited
> to determine how to best accomplish this.
Hi.
If you read the parameters from a file and put them to a matrix,
then all the plots may be produced using a loop like the following.
#some parameters
p <- matrix(1:18, nrow=3, ncol=6)
for (i in 1:nrow(p)) {
plot.spdf(p[i, 1], p[i, 2], p[i, 3], p[i, 4], p[i, 5], p[i, 6])
readline("press Enter to continue")
}
If you use pdf() for sending the graphics to a file, then remove
the "readline" command.
Hope this helps.
Petr Savicky.
More information about the R-help
mailing list