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
Closed

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

JakeRuss opened this issue Dec 23, 2014 · 3 comments

Comments

@JakeRuss
Copy link
Contributor

@JakeRuss JakeRuss 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
Copy link
Contributor Author

@JakeRuss JakeRuss 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.

Loading

@hadley
Copy link
Member

@hadley hadley 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").

Loading

@hadley
Copy link
Member

@hadley hadley commented May 20, 2015

Done in be2eb95

Loading

@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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants