Last active
August 15, 2017 10:45
-
-
Save arcaravaggi/05a1b15fa67a74ba9f0b0614f9a8281c to your computer and use it in GitHub Desktop.
Split column into multiple based on spaces, extra characters, etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Split column into multiple based on spaces, extra characters, etc. | |
df <- data.frame(x= c("crust (5)","things (3)","stuff (8)")) | |
library(tidyr) | |
df2 <- extract(df, x, into = c("pet", "sampSize"), "([^(]+)\\s+\\(([0-9]+).") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment