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

flatten_df to flatten embedded data object before binding #175

Merged
merged 2 commits into from
Jun 12, 2020

Conversation

dsen6644
Copy link
Contributor

@dsen6644 dsen6644 commented Jun 7, 2020

Embedded data fields to be individual columns rather than single list-column. This is more consistent with the mailing list export using the Qualtrics UI.

@juliasilge
Copy link
Collaborator

juliasilge commented Jun 10, 2020

The unit testing for fetch_mailinglist() also needs to be updated.

I don't think we need to mess with the test fixture, only the test itself. You should be able to use either the test fixture or one of your own mailing lists to edit the test to match this new change.

@juliasilge
Copy link
Collaborator

juliasilge commented Jun 10, 2020

Also, I think something isn't working right now with the new code. Here is what happens when I call it on a real mailing list:

library(qualtRics)

all_mailinglists()
#> # A tibble: 2 x 5
#>   libraryId        id              name                   category  folder      
#>   <chr>            <chr>           <chr>                  <chr>     <chr>       
#> 1 UR_8wfG5qsMxuh0… ML_3kszNEnMWzZ… Best sourdough bread … Unassign… /Uncategori…
#> 2 UR_8wfG5qsMxuh0… ML_6xLATuSWeOc… Cats I have known and… Unassign… /Uncategori…
fetch_mailinglist("ML_3kszNEnMWzZA1gN")
#> Error: Argument 1 must have names.
#> Backtrace:
#>     █
#>  1. └─qualtRics::fetch_mailinglist("ML_3kszNEnMWzZA1gN")
#>  2.   ├─dplyr::bind_cols(...) /qualtRics/R/fetch_mailinglist.R:49:2
#>  3.   │ └─rlang::list2(...)
#>  4.   └─purrr::flatten_df(...)
#>  5.     └─dplyr::bind_rows(res, .id = .id)

Created on 2020-06-10 by the reprex package (v0.3.0.9001)

Here is what happens with the version currently in master:

library(qualtRics)

all_mailinglists()
#> # A tibble: 2 x 5
#>   libraryId        id              name                   category  folder      
#>   <chr>            <chr>           <chr>                  <chr>     <chr>       
#> 1 UR_8wfG5qsMxuh0… ML_3kszNEnMWzZ… Best sourdough bread … Unassign… /Uncategori…
#> 2 UR_8wfG5qsMxuh0… ML_6xLATuSWeOc… Cats I have known and… Unassign… /Uncategori…
fetch_mailinglist("ML_3kszNEnMWzZA1gN")
#> # A tibble: 6 x 8
#>   id    firstName lastName email externalDataRef… language unsubscribed
#>   <chr> <chr>     <chr>    <chr> <chr>            <chr>    <lgl>       
#> 1 MLRP… Mary      Smith    webt… <NA>             null     FALSE       
#> 2 MLRP… Barbara   Thomas   tris… <NA>             null     FALSE       
#> 3 MLRP… Thomas    Babbs    bave… <NA>             null     FALSE       
#> 4 MLRP… Nancy     Nanson   mslo… <NA>             null     FALSE       
#> 5 MLRP… Steven    Stevens  bmor… <NA>             null     FALSE       
#> 6 MLRP… Ashley    Ashson   bowm… <NA>             null     FALSE       
#> # … with 1 more variable: embeddedData <list>

Created on 2020-06-10 by the reprex package (v0.3.0.9001)

Copy link
Contributor Author

@dsen6644 dsen6644 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliasilge how about this instead? Only attempts to flatten/bind embedded data when there is embedded data present.

@juliasilge
Copy link
Collaborator

Looks great! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants