Package implementing a do while loop in R.
library(devtools)
devtools::install_github("mrparker909/doWhile")
If you don't mind assigning global variables such as k:
k <<- 0
doWhile({k<<-k+1; print(k)}, {k<5})
rm(k)
If you don't want global variables:
doWhile(do={k=k+1; print(k)}, While={k<5}, vars=list(k=0))
or alternatively:
doWhile({if(!exists("k")) {k<-1} else {k<-k+1}; print(k)}, {k<5})
If you want a return variable:
K = doWhile({k <- k+1; print(k)}, {k<5}, {k}, list(k=0))
print(K)
And the same as above, but more explicit:
K = doWhile(do = {k <- k+1; print(k)},
While = {k<5},
Return = {k},
vars = list(k=0))
print(K)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.