4 ms·
I used R for a while to do visualizations, but I never got to it's more homoiconic side, but I saw since then that it has it. Can you also put code into { 6 },
by middayc 1y ago
I used R for a while to do visualizations, but I never got to it's more homoiconic side, but I saw since then that it has it.
Can you also put code into { 6 }, like { print(6) }?
Does this overwrite R's if or how does the scoping in R work?
- Cosi1125 1y agoThe `6` is the code, I just put the first thing that came to my mind there :D In my example, if you replace it with a more sophisticated code block, R will evaluate it and print out the result of the evaluation. Typically, you'd want to parse the unevaluated code, though: > `if` = function(a, b) { print(substitute(a)); print(substitute(b)) } > if (foo) { print("bar") } foo { print("bar") } It overwrites `if`, in the current scope, of course.