R Under development (unstable) (2024-01-28 r85838 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("R.rsp") R.rsp v0.46.0 successfully loaded. See ?R.rsp for help. > > x <- rstring("A random integer in [1,100]: <%=sample(1:100, size=1)%>\n") > cat(x) A random integer in [1,100]: 51 > > # Passing arguments > x <- rstring("A random integer in [1,<%=K%>]: <%=sample(1:K, size=1)%>\n", args=list(K=50)) > cat(x) A random integer in [1,50]: 50 > > x <- rstring("A random integer in [1,<%=K%>]: <%=sample(1:K, size=1)%>\n", args=list(K=50), verbose = TRUE) rstring() for default... Length of RSP string: 57 rstring() for RspString... Assigning RSP arguments to processing environment... Environment: R_GlobalEnv RSP arguments: List of 1 $ K: num 50 Variables assigned: [1] K member data.class dimension objectSize 1 K numeric 1 56 Assigning RSP arguments to processing environment...done Parse RSP string to RSP document... Parse environment: R_GlobalEnv member data.class dimension objectSize 1 K numeric 1 56 Parsing RSP string... Compile until: '*' Return as: 'RspDocument' Dropping 'empty' RSP comments... Length of RSP string before: 57 No 'empty' RSP comments found. Dropping 'empty' RSP comments...done Dropping 'paired' RSP comments... Length of RSP string before: 57 No 'paired' RSP comments found. Dropping 'paired' RSP comments...done Processing RSP preprocessing directives... Length of RSP string before: 57 No RSP preprocessing directives found. Processing RSP preprocessing directives...done Processing RSP expressions... Length of RSP string before: 57 Number of (unparsed) RSP expressions found: 2 Length of RSP string after: 57 Processing RSP expressions...done Parsing RSP string...done RspDocument: Source: NA Total number of RSP constructs: 5 Number of RspCodeChunk(s): 2 Number of RspText(s): 3 Content type: NA Parse RSP string to RSP document...done rstring() for RspDocument... Coerce RSP document to source code... Language: R Generated source code: ## = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ## This is a self-contained R script generated from an RSP document. ## It may be evaluated using source() as is. [...] ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## RSP source code script [END] ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Coerce RSP document to source code...done rstring() for RspRSourceCode... Environment: R_GlobalEnv rstring() for RspRSourceCode...done rstring() for RspDocument...done rstring() for RspString...done rstring() for default...done > cat(x) A random integer in [1,50]: 31 > > proc.time() user system elapsed 0.60 0.18 0.75