A lot is personal preference.  I use Perl since it is very good at doing any
of the preprocessing that I need to setup data for R; e.g., reading a text
file, extracting the data and then setting it up in a format for R.  I can
then invoke R from the script.  Here is a sample of come Perl code that
actually calls some other Perl scripts and then invokes R (this script logs
onto a UNIX system, extracts some data, preprocesses with other Perl scripts
and then calls R with a set of commands with the appropriate substitutions:


 use Net::Telnet;
my $t = Net::Telnet->new(Timeout => 900, Host => $ftpName); #setup the host
$t->login($user, $password);  #login
print STDERR $t->cmd("acctcom $perfDir/pacct.$yesterday
>/tmp/pacct.$yesterday.$hostname");
#
# create the FTP commands to xfer the data
#
my $ftp = Net::FTP->new($ftpName) or die "FTP new";
$ftp->login($user, $password) or die 'login';
$ftp->cwd($perfDir) or die 'cwd';
ftpGet($ftp, "SRVL_serval_${yesterday}.longps",
"longps.$hostname.$yesterday");
ftpGet($ftp, "SRVL_serval_${yesterday}.sar", "sar.$hostname.$yesterday");
ftpGet($ftp, "/tmp/pacct.$yesterday.$hostname",
"pacct.$yesterday.$hostname");
ftpGet($ftp, "/u01/WIData/audit/user.log", "user.log");
ftpGet($ftp, "/u01/WIData/audit/userdet.log", "userdet.log");
$ftp->quit();

system("perl /perf/bin/sarextr.pl sar.$hostname.$yesterday");
system("perl /perf/bin/driveuse.pl sar.$hostname.$yesterday");
system("awk -f /perf/bin/longps.awk longps.$hostname.$yesterday
>ps.$hostname.$yesterday");
system("perl /perf/bin/psextrV2.pl ps.$hostname.$yesterday");
system("perl /perf/bin/sumprocs.pl ps.$hostname.$yesterday.cpu");
system("perl /perf/bin/userdet.pl userdet.log >userdet.txt");
system("perl /perf/bin/acct-extr.pl pacct.$yesterday.$hostname");

open RBATCH, ">rcmds.txt" or die "RBATCH";
#
# create the R command file
#
print RBATCH <<EOF;
setwd('/perf/data')
load('/perf/data/.RData')   # restore environment
my.stats('start')
postscript(file="proc.$hostname.$yesterday.ps", width=10, height=7.5,
    horizontal=TRUE, family="Courier")
plot.procs("ps.$hostname.$yesterday")
plot.sar("sar.$hostname.$yesterday.srx")
source('/perf/bin/Accounting Functions.R')
acct.log <- acct.read.file("pacct.${yesterday}.${hostname}.pacct")
acct.proc.cpu(acct.log,
    sar.overlay=c("sar.$hostname.$yesterday.srx",2))
acct.cpu.polygon(acct.log[acct.log\$cmd=='wiqt', ])
acct.count.polygon(acct.log, y.limit=500)
plot.srx.file("sar.$hostname.$yesterday.srx", post.script=F, layout=c(5,5))
dev.off()
my.stats('done')
EOF
print STDERR $t->cmd("rm /tmp/pacct.$yesterday.$hostname");
$t->close();
close RBATCH;
system("\"C:/Program Files/R/rw2010/bin/Rterm.exe\" --max-mem-size=512M
--no-save <rcmds.txt >$hostname.$yesterday.batch");





On 12/2/05, Molins, Jordi <[EMAIL PROTECTED]> wrote:
>
>
> I am using R in Windows. I see that I will have to use batch processes
> with
> R. I will have to read and write text files, and run some R code; probably
> some external code too. I have never done scripting. Is there any document
> that explains simple steps with examples? I also have heard that Python is
> a
> good scripting language. Is it worth the effort? (I do not have too much
> free time, so if I could do without, much better ...).
>
> Has anybody strong opinions on that? Past experiences?
>
> Thank you!
>
> Jordi
>
>
>
>
> --------------------------------------------------------------------------------
> The information contained herein is confidential and is inte...{{dropped}}
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to