Separating a bigram ending up with more columns than expected

You just have a little syntax error here, the sep argument shouldn't be inside c(), see this example

library(tidyr)
library(dplyr)

bigram <- data.frame(stringsAsFactors = FALSE,
                     word = c("sherif's department", "sherif's car")
                     )
bigram %>% 
    separate(word, into =c('first_word', 'second_word'), sep = '\\s')
#>   first_word second_word
#> 1   sherif's  department
#> 2   sherif's         car

Created on 2019-11-24 by the reprex package (v0.3.0.9000)

Note: For future posts, please make your questions providing a proper REPRoducible EXample (reprex) as the one above.

2 Likes