Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-Forge #5527] Different scoping rule when assigning by reference a new column #30

Closed
arunsrinivasan opened this issue Jun 8, 2014 · 0 comments
Assignees
Labels
Milestone

Comments

@arunsrinivasan
Copy link
Member

Submitted by: Michele Carriero; Assigned to: Arun ; R-Forge link

Given the following table dt:

dt<-data.table(id=1:5, var=letters[1:5])

If I need to retrieve programmatically a column I use eval(parse(text=variable)). But when the variable, containing (part of) the column name to retrieve, is also named alike another column in the table I have two different outcomes:

id<-"va"
dt[, eval(parse(text=paste0(id,"r")))]
# [1] "a" "b" "c" "d" "e"

dt[, id2:=eval(parse(text=paste0(id,"r")))]
# Error in parse(text = paste0(id, "r")) : <text>:1:2: unexpected symbol
1: 1r
    ^

I thought that the above was not intended to be so. I would expect the same result (probably the second).

@arunsrinivasan arunsrinivasan modified the milestone: v1.9.4 Jun 19, 2014
@arunsrinivasan arunsrinivasan self-assigned this Jun 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant