[R] Using evaluate-deparse-substitute
Adaikalavan Ramasamy
gisar at nus.edu.sg
Thu Feb 20 10:41:05 CET 2003
Being the lazy soul I am, I wish to write a function to replace saying
ls(pattern=...) everytime. Here is what I have:
lsp <- function(x){
y <- eval(deparse(substitute(x)))
print(y) # CHECK
print( ls(pattern = eval(y)) ) # TRY 1
print( ls(pattern = eval(deparse(substitute(x)))) ) # TRY 2
}
Suppose I have
rubbish.in = rubbish.out = grub <- 1
I get the following when I try
> lsp(rub)
[1] "rub"
character(0)
character(0)
Can someone explain/help with this? Thank you very much.
More information about the R-help
mailing list