Skip to content

as.vector doesn't work on categorical array expression #457

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

Closed
gergness opened this issue Jun 5, 2020 · 2 comments
Closed

as.vector doesn't work on categorical array expression #457

gergness opened this issue Jun 5, 2020 · 2 comments
Labels

Comments

@gergness
Copy link
Contributor

gergness commented Jun 5, 2020

Also would be nice if it worked on a VarDef because that's what we get from deriveArray().

Will make sense to work on this when we figure out the derived subvariable metadata that is currently blocking #453

library(crunch)
login()

ds <- newDataset(
    data.frame(x1 = letters[1:2], x2 = letters[1:2]),
    name = "as.vector derived arrays issue"
)

as.vector(
    crunch:::CrunchExpr(
        expression = deriveArray(
            list(VarDef(ds$x1 == "a", name = "x1_a"), VarDef(ds$x2 == "a", name = "x2_a")), 
            name = "derived array"
        )$derivation, 
        dataset_url = self(ds), 
        filter= list()
    )
)

#>  Error in (function (classes, fdef, mtable)  : 
#>    unable to find an inherited method for function ‘tuple’ for signature ‘"VariableEntity"’ 
@gergness
Copy link
Contributor Author

gergness commented Jun 5, 2020

Also in as.vector, would be nice if we could get it to work for Subvariables.

ds$x <-  deriveArray(list(VarDef(ds$x1 == "a", name = "x1_a"), VarDef(ds$x2 == "a", name = "x2_a")), name = "derived array")

as.vector(ds$x["x1_a"])
#> Error in as.vector(ds$x["x1_a"]) : 
#>  no method for coercing this S4 class to a vector

class(ds$x["x1_a"])
#> [1] "Subvariables"
#> attr(,"package")
#> [1] "crunch"

@gergness gergness changed the title as.vector doesn't work on derived categorical array as.vector doesn't work on categorical array expression Jun 5, 2020
@malecki
Copy link
Contributor

malecki commented Aug 10, 2020

no longer blocking expression-based addSubvariable, so need for this is diminished; also, as.vector that gave you a bunch of vectors doesn’t seem quite the right fit either. Will need to see if related needs come up again elsewhere.

@malecki malecki closed this as completed Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants