Github user shivaram commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7318#discussion_r34595103
  
    --- Diff: R/pkg/inst/tests/test_sparkSQL.R ---
    @@ -949,6 +949,17 @@ test_that("fillna() on a DataFrame", {
       expect_identical(expected, actual)
     })
     
    +test_that("crosstab() on a DataFrame", {
    +  rdd <- lapply(parallelize(sc, 0:5), function(x) {
    +    list(paste0("a", x %% 3), paste0("b", x %% 2))
    +  })
    +  df <- toDF(rdd, list("a", "b"))
    +  ct <- crosstab(df, "a", "b")
    +  ordered <- ct[order("a_b"),]
    +  expected <- data.frame("a_b" = c("a0", "a1", "a2"), "b0" = c(1, 1, 1), 
"b1" = c(1, 1, 1))
    --- End diff --
    
    I think I figured out what is going on here -- The `expected` data.frame 
creates the column `a_b` as factors. You can pass in `stringsAsFactors=F` to 
the data.frame constructor to avoid this.
    
    Also I think the `order` command above should probably be `ordered <- 
ct[order(ct$a_b),]` to get all the rows back out of it. It still associates row 
names which makes it not identical (you can do `row.names(ordered) <- NULL`).
    A simpler check might be to just get one or two rows from `ct` and then 
compare them with `expected`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to