Skip to content

fct_c() should not require a list as an argument #42

Closed

Description

@AmeliaMN

Related to this issue.

If you have the following data,

ds <- factor(c(rep("Male", times=2), rep("Female", times=4), rep("Gender non-conforming", times=2)))
test <- ds[1:4]
train <- ds[5:8]

The base c() does not work as expected:

c(test, train)
[1] 3 3 1 1 1 1 2 2

but you can list() and unlist()

unlist(list(test, train))
[1] Male                  Male                  Female                Female                Female                Female               
[7] Gender non-conforming Gender non-conforming
Levels: Female Gender non-conforming Male

That's annoying! I like fct_c() better because then I don't have to type unlist(), but I still have to give a list.

fct_c(list(test, train))
[1] Male                  Male                  Female                Female                Female                Female               
[7] Gender non-conforming Gender non-conforming
Levels: Female Gender non-conforming Male

I wish I could just fct_c(test, train).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions