1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
<%-----------------------------------------------------------------
This is an RSP-embedded R script that compiles into an R script
name 'ifdef.R' that depending on preprocessing variable 'DEBUG'
either defines function (DEBUG=FALSE) or an R script evaluating
the function body in the global environment (DEBUG=TRUE)
EXAMPLE:
R.rsp::rfile('ifdef.R.rsp', args=list(DEBUG=TRUE))
Rscript -e "R.rsp::rfile('ifdef.R.rsp')" -DEBUG=TRUE
-----------------------------------------------------------------%>
<%@logical DEBUG="${DEBUG}" default="FALSE"%>
# RSP preprocessing variable 'DEBUG' <%@ifdef name="DEBUG"%>exists.<%@else%>does not exists.<%@endif%>
# RSP preprocessing variable 'UNKNOWN' <%@ifndef name="UNKNOWN"%>does not exists.<%@else%>exists.<%@endif%>
<%@ifeq DEBUG="FALSE"%>
make_addition = function(a, b) {
<%@else%>
a = 1
b = 2
<%@endif%>
c=a+b
plot(c)
<%@ifeq DEBUG="FALSE"%>
return(c)
}
<%@endif%>
|