File: ifdef.R.rsp

package info (click to toggle)
r-cran-r.rsp 0.46.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,472 kB
  • sloc: javascript: 612; tcl: 304; sh: 18; makefile: 16
file content (27 lines) | stat: -rw-r--r-- 919 bytes parent folder | download | duplicates (2)
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%>