Comments (4)
I'm not sure what you're expecting here. But please note that rlang::duplicate()
is for expert usage only. It's a direct wrapper around the C-level function of the R API which most certainly works as expected according to its specifications.
from rlang.
Thank you for the clarification. I understand that rlang::duplicate()
is a powerful function that directly wraps a C-level function in the R API. I mean the names of dt1
shouldn't change when I change dt2 by reference just like what dt3
worked. dt3
is a data.table created via dt1[TRUE]
which has been revealed to do shallow copy.
from rlang.
dt2
has removed the name "mpg" in dt1
dt2[, mpg := NULL]
x
#> [1] "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" "carb"
names(dt1)
#> [1] "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" "carb"
from rlang.
It's not that it's powerful, it's that it's extremely low level, and you shouldn't expect any high level semantics from it. Also it's mostly meant for prototyping C code from R and should generally not be used in user or package code.
dt2 has removed the name "mpg" in dt1
Yes since it's a shallow copy the attributes list is not duplicated, which means that if you modify the names in place later on you'll get side effects. It's all working as expected from the perspective of these very low level tools.
from rlang.
Related Issues (20)
- `error_arg()` and `error_call()` should have better fall backs when called directly HOT 3
- Updates to `topic-error-call`
- Add `check_named()` to standalone file.
- Add `check_has_names()`
- Missing Rterm.exe HOT 1
- Request: Export type-checking function(s) (e.g. `standalone-check-types`) HOT 2
- Feature request: add function to modify an atomic vector in place HOT 1
- Allow custom descriptions for `obj_type_friendly()` HOT 1
- Document different behaviors of `error` for `check_dots_used()`
- include variable values in backtrace when known?
- `rlang::inform()` messages should conform to `base::message()` HOT 3
- Unnamed `exprs()` HOT 1
- `on_package_load()` should evaluate in a local env
- `hash` generates different results on identical objects (even with same memory address) HOT 11
- `arg_match()` error message only mentions the first element of `arg` HOT 2
- is_syntactic_literal() returns TRUE in the presence of attributes.
- Confusion about `enexprs` HOT 1
- [FR] Allow showing expression instead of values in `arg_match()` error message
- Helper to wrap error with a hint HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rlang.