I am trying to use the sdf_pivot() function in sparklyr to "gather" a long format data frame into a wide format. The values of the variables are strings that I would like to concatenate.
Here is a simple example that I think should work but doesn't:
library(sparkylr)
d <- data.frame(id=c("1", "1", "2", "2", "1", "2"),
x=c("200", "200", "200", "201", "201", "201"),
y=c("This", "That", "The", "Other", "End", "End"))
d_sdf <- copy_to(sc, d, "d")
sdf_pivot(d_sdf, id ~ x, paste)
What I'd like it to produce is:
| id | `200` | `201` |
|====|=============|=================|
| 1 | "This That" | "End" |
| 2 | "The" | "Other End" |
Unfortunately this gives me an error stating:
Error in as.vector(x, "character") :
cannot coerce type 'environment' to vector of type 'character'
I also tried using "collect_list"
and that gives me this error:
Error: java.lang.IllegalArgumentException: invalid method collect_list
for object 641
Is there a way to do what I'm attempting to do?