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

Should separate's 'extra' argument have a fill option? #49

Closed
JakeRuss opened this issue Dec 23, 2014 · 3 comments

Comments

@JakeRuss
Copy link

commented Dec 23, 2014

Suppose I have a data frame where a column contains information that I would like to separate, but only some of the rows have the second part. Would it make sense to have an option to fill the empty cells with NAs?

My use case is college football rankings tables. In the teams column they also list the first place votes, if any, which I want saved as its own column. Right now I'm using stringr + regex to extract the votes, set the ones without votes to NA or zero, and then scrub the numeric information from the teams column.

Could this potentially be improved with separate? Something like,
separate(col, into = c("col1", "col2"), sep = ",", extra = "fill") or fill = TRUE, or fill = "value" ?

My thought would be for each row, if delimiter exists, then split, otherwise col stays in col1 and col2 would be filled with NA or the desired value.

Thoughts?

@JakeRuss

This comment has been minimized.

Copy link
Author

commented Dec 23, 2014

I now see that extra = "merge" already does the fill = NA part of what I suggest here. I would just delete this but I'm going to leave it up and see if anyone seconds the fill = "value" part.

@hadley

This comment has been minimized.

Copy link
Member

commented May 20, 2015

Just realised this was a duplicate of what I wanted. I think fill = "left" and fill = "right" make the most sense to me (and default to fill = "none").

@hadley

This comment has been minimized.

Copy link
Member

commented May 20, 2015

Done in be2eb95

@hadley hadley closed this May 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.