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

p.178: stringr 1.5.0のstr_detect()関数のエラー #6

Open
ito4303 opened this issue Feb 24, 2023 · 0 comments
Open

p.178: stringr 1.5.0のstr_detect()関数のエラー #6

ito4303 opened this issue Feb 24, 2023 · 0 comments

Comments

@ito4303
Copy link

ito4303 commented Feb 24, 2023

6.2節、p.178 の stopwords を設定するところのコードですが、stringr 1.5.0 の str_detect ではエラーが発生します。

> stopwords <- readr::read_lines(stopword_url) %>%
+   # 空の文字列("")を削除
+   .[stringr::str_detect(., "") == TRUE]
Error in `stringr::str_detect()`:
! `pattern` can't be the empty string (`""`).
Run `rlang::last_error()` to see where the error occurred.

stringr 1.5.0 で仕様が変わったようですね。
https://www.tidyverse.org/blog/2022/12/stringr-1-5-0/#empty-patterns

とりあえず、

  .[stringr::str_detect(., ".+") == TRUE]

で、回避できています。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant