追記(2017/05/21):
ツイートの主によるやり方解説ブログはこちら。
これを描きたい。が、元データはどこを見ればいいのかよくわからず調べた時のメモ。
続きを読むThe #wannacry attackers — if they can cash out before authorities find them — just topped $35K USD pic.twitter.com/UBQOrz1yJ0
— Боб Рудіс (@hrbrmstr) 2017年5月14日
追記(2017/05/21):
ツイートの主によるやり方解説ブログはこちら。
これを描きたい。が、元データはどこを見ればいいのかよくわからず調べた時のメモ。
続きを読むThe #wannacry attackers — if they can cash out before authorities find them — just topped $35K USD pic.twitter.com/UBQOrz1yJ0
— Боб Рудіс (@hrbrmstr) 2017年5月14日
例えば、適当な文字列からaで始まる単語を抜き出してみる(こんなことはstr_locate_all()
を使わなくてもできるけど、まあ例ということで)
library(stringr) library(purrr) x <- c("asymmetry between apple and banana", "aspiration after surgery") # \\p{Ll}はunicode property nameというやつらしい。 ptn <- "a[\\p{Ll}]+"続きを読む
追記(2017/05/13): useBytes = TRUE
にした場合は、regmatches()
で抜き出すのはいけるけど、regmatches<-
で置換するのはエラーになる。うーん…
x <- "<img src='test.png' alt='🍉'>" m <- gregexpr("<\\s*[Ii][Mm][Gg]\\s+[Ss][Rr][Cc]\\s*=\\s*[\"']([^\"']+)[\"']", x, useBytes = TRUE) regmatches(x, m) #> [[1]] #> [1] "<img src='test.png'" #> regmatches(x, m) <- toupper(regmatches(x, m)) #> Error in nchar(u) : #> number of characters is not computable in "bytes" encoding, element 1
unicodeのことは分からないけど引き続きメモ。
続きを読むこういう問題に悩まされていて、どうすればいいか調べる途中のメモ
具体的に言うとこのエラーをなんとかしたい。
# devtools::install_github("hadley/emo") wm <- emo::ji("watermelon") as.character(wm) #> [1] "\xf0\u009f\u008d\u0089" gregexpr(".", as.character(wm), perl = TRUE) #> Error in gregexpr(".", as.character(wm), perl = TRUE) : #> invalid input '拷' in 'utf8towcs'続きを読む
Windowsだけで起こるこのバグのせいでinstall.packages()
が失敗するという話があって気になって調べていた。
17261 – file.info returns