Wacek Kusnierczyk wrote: > Rolf Turner wrote: > >> (Note: You *cannot* have spurious objects name "FALSE" (and not equal >> to FALSE) hanging around; R won't let you. That's why you use FALSE and >> not F.) >> > > yes you can, r will let you: > > assign("FALSE", TRUE) > ls() > # see "FALSE" > get("FALSE") > # see TRUE > > this does not matter much, as r will think FALSE when you type FALSE, > rather than look up your variable, and you'd have to use backticks to > get the latter. but you may want to be more careful when playing with > promises and deparsing them in your functions: > > f = function(n, m, replace, env) { > replace = get(deparse(substitute(replace)), env) > sample(1:n, m, replace=replace) > } > > f(n = 10, m = 100, replace = FALSE, env = e) > # given the above, succeeds > oops, was too quick. the following was meant:
f = function(n, m, replace, env) { replace = get(deparse(substitute(replace)), env) sample(1:n, m, replace=replace) } f(n = 10, m = 100, replace = FALSE, env = globalenv()) # given the above, succeeds or better (i.e., worse): f = function(n, m, replace, env=parent.frame()) { replace = get(deparse(substitute(replace)), env) sample(1:n, m, replace=replace) } f(n = 10, m = 100, replace = FALSE) # given the above, succeeds vQ (rolf, apologies for the boring pedantry) ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.