I tried to find a sentence where two specified words occurred together with less than 4 Chinese characters apart .
input <- data.frame(
stringsAsFactors = FALSE,
x = c('我有一張股票','我有玩股票','我買股票','我看了股票')
I expected that all items should have been returned but only two items were returned. Could anyone help to correct my lines to return all items? Besides, when use str_subset, the length of input$x needs to be multiple of p. For example, an error will occur (longer object length is not a multiple of shorter object length) if input$x is length of 5 and p is length of 2. How can I avoid this error? thanks.