# EXAMPLE #1: Output random number
rsp(text="A random number in [1,100]: <%=sample(1:100, size=1)%>
")
# EXAMPLE #2: Assign and output random number
rsp(text="A random number in [1,100]: <%= x <- sample(1:100, size=1); %>
")
cat(sprintf("The random number generated by the RSP document was: %d
", x))
Run the code above in your browser using DataLab