Comments (3)
Thanks a lot for the breakdown John! That makes sense now - no peculiar side effects as I had previously thought.
from wrapr.
Glad that helped! The substitution stuff can get confusing. Your question gave me the idea of printing more in the debug so one can see what is going on. Like the idea of "breakdown" slowing things down enough so one can see the steps.
from wrapr.
Actually wrapr
is working as intended on the example. Probably not doing what you want, but you may be able to work into it if you are interested.
Here is your example with debugging turned on.
reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-11-13
library("wrapr")
packageVersion("wrapr")
#> [1] '1.0.1'
params.list <- list(
MQT_TBL_1_ = 'dir_p_pts',
MQT_AGG_TYPE_ = 'max'
)
applyAgg <- function(params.list.agg){
wrapr::let(
alias=list(MQT_TBL_1_=params.list.agg$MQT_TBL_1_),
expr={
print(params.list.agg$MQT_TBL_1_) # This doesn't work (aliased)
print(params.list.agg[["MQT_TBL_1_"]]) # This does work (aliased)
print(params.list.agg$MQT_AGG_TYPE_) # This does work (not aliased)
print(params.list.agg[["MQT_AGG_TYPE_"]]) # This does work (not aliased)
},
debugPrint = TRUE)
}
applyAgg(params.list)
#> $MQT_TBL_1_
#> [1] "dir_p_pts"
#>
#> {
#> print(params.list.agg$dir_p_pts)
#> print(params.list.agg[["MQT_TBL_1_"]])
#> print(params.list.agg$MQT_AGG_TYPE_)
#> print(params.list.agg[["MQT_AGG_TYPE_"]])
#> }
#> NULL
#> [1] "dir_p_pts"
#> [1] "max"
#> [1] "max"
I've modified wrapr
's debug mode to print the alias map in addition to the substituted expression.
wrapr::let()
is designed to substitute code symbols (explicit variables and names of columns) for other symbols.
Notice that wrapr::let()
only performed a substitution in the first of the four statements.
The rules detailed are:
- Statement 1 gets substituted as the symbol
MQT_TBL_1_
is seen as a code entity (the right-hand-side of a$
operator, I think this is actually a special case inwrapr
due to some details of howR
code is represented). - Statement 2 does not get substituted as
wrapr
does not perceive the"MQT_TBL_1_"
as a bit of code, but instead as a constant. It might be argued we would want to special case this as we did with$
, but that would be a bit more difficult. - As you mentioned Statement 3 and 4 are properly left alone.
Some of the intent and rules of wrapr::let()
are documented here.
from wrapr.
Related Issues (15)
- wrapr::let: "stringsubs" as the subsMethod default HOT 2
- Feature Request: wrapr::let map a name to something 'other than a name.' HOT 2
- Invalid names in alias values HOT 1
- wrapr::qc doesnt replace c always HOT 4
- Some inconsistencies with `%.>%` and parens use HOT 4
- How can you use dplyr::case_when progromatically with wrapr::let? HOT 18
- Character encoding causes order to error-out HOT 2
- Licensing : possible to use LGPL instead? HOT 5
- Macros in R, as.call HOT 6
- suggestion for qc function HOT 9
- Unexpected Behavior HOT 2
- add international character tests HOT 1
- unexpected behaviour: qc() removes leading zeroes HOT 5
- Feature Request: Option to enable benchmarking on pipes HOT 1
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 wrapr.