Re: [R] what is best for scripting?

From: jim holtman <>
Date: Fri 02 Dec 2005 - 23:34:07 EST

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

# 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",
ftpGet($ftp, "/u01/WIData/audit/user.log", "user.log");
ftpGet($ftp, "/u01/WIData/audit/userdet.log", "userdet.log");
system("perl /perf/bin/ sar.$hostname.$yesterday");
system("perl /perf/bin/ sar.$hostname.$yesterday");
system("awk -f /perf/bin/longps.awk longps.$hostname.$yesterday

system("perl /perf/bin/ ps.$hostname.$yesterday");
system("perl /perf/bin/ ps.$hostname.$yesterday.cpu");
system("perl /perf/bin/ userdet.log >userdet.txt");
system("perl /perf/bin/ pacct.$yesterday.$hostname");

open RBATCH, ">rcmds.txt" or die "RBATCH";

# create the R command file

print RBATCH <<EOF;
load('/perf/data/.RData') # restore environment my.stats('start')
postscript(file="proc.$hostname.$", width=10, height=7.5,

    horizontal=TRUE, family="Courier")
plot.sar("sar.$hostname.$yesterday.srx") source('/perf/bin/Accounting Functions.R') acct.log <-"pacct.${yesterday}.${hostname}.pacct") acct.proc.cpu(acct.log,


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))
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 <> 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}}
> ______________________________________________
> mailing list
> PLEASE do read the posting guide!

Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

	[[alternative HTML version deleted]]

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Fri Dec 02 23:39:06 2005

This archive was generated by hypermail 2.1.8 : Sat 03 Dec 2005 - 02:28:06 EST