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

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

Closed
AmeliaMN opened this issue Sep 26, 2016 · 0 comments
Closed

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

AmeliaMN opened this issue Sep 26, 2016 · 0 comments

Comments

@AmeliaMN
Copy link
Contributor

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).

@hadley hadley closed this as completed in f07aace Dec 30, 2016
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

No branches or pull requests

1 participant