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

adds better support for dplyr::mutate + tests #24

Merged
merged 1 commit into from
Mar 5, 2015
Merged

Conversation

adgaudio
Copy link
Contributor

This PR wraps dplyr::mutate the same way we do for filter and arrange so it's more usable in tidyjson expressions.

@jeremystan

Solves this bug:

>      key_employees <- companies %>%
+        as.tbl_json %>%
+        spread_values(
+          name = jstring("name")
+        ) %>%
+        mutate(
+          company.sort_order = rank(name)
+        ) %>%
+        enter_object("relationships") %>%
+        gather_array("relationship.index") %>%
+        spread_values(
+          is.past = jlogical("is_past"),
+          name = jstring("person", "permalink"),
+          title = jstring("title")
+        )
Error: is.tbl_json(x = x) is not TRUE

@jeremystan
Copy link

There is a documentation change to allowed types that may be because you ran document() using older code that hadn't been run with document? If so, that may be acceptable (though we should verify the documentation is correct).

@adgaudio
Copy link
Contributor Author

Also, what do you think about those factor(...) calls in the test. Are we okay with them in there? (They are necessary to make tests pass).

expect_identical(
result,
tbl_json(
data.frame(

Choose a reason for hiding this comment

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

Rather than having to call factor() above, consider either using data_frame (may create a different object than data.frame? not sure), or instead use data.frame(..., stringsAsFactors = FALSE).

@adgaudio
Copy link
Contributor Author

@jeremystan

@jeremystan
Copy link

+1

jeremystan pushed a commit that referenced this pull request Mar 5, 2015
adds better support for dplyr::mutate + tests
@jeremystan jeremystan merged commit e2f6ce4 into master Mar 5, 2015
@jeremystan jeremystan deleted the mutate branch March 5, 2015 23:08
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