Loading...
 
Tiki and PluginR

Tiki and PluginR


Re: a better R workflow on a webserver

posts: 32 France

I think I got some generic solution
Th R script is:

create_Rda.R
args < - commandArgs(trailingOnly = TRUE)
dir < - args[1]
input.path < - args[2]
output.path < - args[3]

setwd(dir)
s4r < - read.delim(file=input.path, header=TRUE, sep="|", skip="1", quote="")
save(s4r, file=output.path)


Then it is called by the shell script which crontab launches

#!/bin/bash

STATS_FOLDER="export_stats_files/"
STATS_FILE="stats_4_R.txt" # this is the csv which contains the data in STATS_FOLDER
RDA_FILE="stats_4_R.Rda" # This will be created in STATS_FOLDER
RDA_FILE_TMP="stats_4_R_tmp.Rda" # this is a temporary file to ensure RDA_FILE remains available during processing

/usr/bin/Rscript create_Rda.R "${STATS_FOLDER}" "${STATS_FILE}" "${RDA_FILE_TMP}"

echo -n "Rda file "
diff -q "${STATS_FOLDER}/${RDA_FILE_TMP}" "${STATS_FOLDER}/${RDA_FILE}" > /dev/null  && (echo "OK"; /bin/rm "${STATS_FOLDER}/${RDA_FILE_TMP}" ) || (echo "Replace"; /bin/mv "${STATS_FOLDER}/${RDA_FILE_TMP}" "${STATS_FOLDER}/${RDA_FILE}")

Why Register?

Register at tiki.org and you'll be able to use the account at any *.tiki.org site, thanks to the InterTiki feature. A valid email address is required to receive site notifications and occasional newsletters. You can opt out of these items at any time.