David Rosenberg
2009-Mar-17 17:25 UTC
[Rd] Putting demo shell scripts, text files, and RScript files with a package?
I've written a package to assist with using R in Hadoop Streaming. The main point of the package is to help make command-line runnable RScript files. I'd like to provide a demo RScript file, a demo data file (e.g. a plaintext file, not something already processed by R) , as well as demo bash shell scripts that demonstrate how to run the job from the command line and in a Hadoop cluster. My best idea so far for distributing these files is to package the contents of these files as a list of strings in a data file in the data directory, and include a function in the package, say generateDemoFolder(targetDir), that writes the files to a user- specified directory, ready for use from the command line. Any suggestions? Thanks, David
Martin Maechler
2009-Mar-18 07:52 UTC
[Rd] Putting demo shell scripts, text files, and RScript files with a package?
>>>>> "DR" == David Rosenberg <drosen at stat.berkeley.edu> >>>>> on Tue, 17 Mar 2009 13:25:46 -0400 writes:DR> I've written a package to assist with using R in Hadoop Streaming. DR> The main point of the package is to help make command-line runnable DR> RScript files. I'd like to provide a demo RScript file, a demo data DR> file (e.g. a plaintext file, not something already processed by R) , DR> as well as demo bash shell scripts that demonstrate how to run the job DR> from the command line and in a Hadoop cluster. DR> My best idea so far for distributing these files is to package the DR> contents of these files as a list of strings in a data file in the DR> data directory, and include a function in the package, say DR> generateDemoFolder(targetDir), that writes the files to a user- DR> specified directory, ready for use from the command line. I think you've overlooked the possibility of <sourcePkg>/inst/ I would use something like <sourcePkg>/inst/scripts/ which will become <installedPkg>/scripts/ [accessible from within R by system.file("scripts", package= "<yourPkg>") One "famous" example being the R scripts for Venables&Ripley's MASS book, available from all R installations via system.file("scripts", package="MASS") e.g. > list.files(system.file("scripts", package="MASS")) [1] "ch01.R" "ch02.R" "ch03.R" "ch04.R" "ch05.R" "ch06.R" "ch07.R" "ch08.R" "ch09.R" [10] "ch10.R" "ch11.R" "ch12.R" "ch13.R" "ch14.R" "ch15.R" "ch16.R" or > source(system.file("scripts", "ch01.R", package="MASS")) { which ends in an error: It's not made for source(); it might well be source()able if 'if(interactive()) ' where replaced by 'if(dev.interactive()) ' } Martin Maechler, ETH Zurich
Reasonably Related Threads
- Processing a large number of files
- where is "average shifted histogram"?
- getCPUStats of a domain by a non-root user - libvirtError: Requested operation is not valid: cgroup CPUACCT controller is not mounted
- NAMESPACE
- Re peated ANOVA or nested ANOVA, or parallel one way ANOVA six times?