colearendt / tidyjson

Tidy your JSON data in R with tidyjson
Other
182 stars 14 forks source link

Add compatibility with dplyr programming data masking #129

Closed Daveyr closed 3 years ago

Daveyr commented 4 years ago

With dplyr verbs it is possible to redirect environment variables as data variables, for instance:

var_summary <- function(data, var) {
  data %>%
    summarise(n = n(), min = min({{ var }}), max = max({{ var }}))
}

It would be very helpful if tidyjson verbs could do the same, e.g.

jsonDF <- function(data, object){
  data %>%
    enter_object({{object}}) %>%
    spread_all()
}
ramiromagno commented 3 years ago

I second this.

colearendt commented 3 years ago

PR that implements this is up! Please give it a try and LMK if any issues! https://github.com/colearendt/tidyjson/pull/132

ramiromagno commented 3 years ago

Thank you for your lightning response!

Just a question: in your PR you use rlang::quo, should it not be rlang::enquo?

Suggestion: perhaps add a test too with the embrace operator (as opposed to having only the !!! operator).

colearendt commented 3 years ago

I thought I did add a test with the embrace operator?

Also, I think quos vs. enquos is the choice, and I don’t think enquos is needed (isn’t it for names?). I have to admit that I often forget the distinctions haha - you might be right. I’ll take a look later!

Sent from my iPhone

On Jan 2, 2021, at 11:10 AM, Ramiro Magno notifications@github.com wrote:



Thank you for your lightning response!

Just a question: in your PR you use rlang::quo, should it not be rlang::enquo?

Suggestion: perhaps add a test too with the embrace operator (as opposed to having only the !!! operator).

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/colearendt/tidyjson/issues/129#issuecomment-753491537, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFQBVVSXUF2JTYFVQ3AMCFDSX5ARFANCNFSM4PDR7GWA.