【发布时间】:2015-08-27 22:33:53
【问题描述】:
我试图在由字符串组成的数据框中识别唯一的 unicode 值。我曾尝试使用 grep 函数,但遇到以下错误
Error: '\U' used without hex digits in character string starting ""\U"
一个示例数据框
time sender message
1 2012-12-04 13:40:00 1 Hello handsome!
2 2012-12-04 13:40:08 1 \U0001f618
3 2012-12-04 14:39:24 1 \U0001f603
4 2012-12-04 16:04:25 2 <image omitted>
73 2012-12-05 06:02:17 1 Haha not white and blue... White with blue eyes \U0001f61c
40619 2015-05-08 10:00:58 1 \U0001f631\U0001f637
grep("\U", dat$messages)
数据
dat <-
structure(list(time = c("2012-12-04 13:40:00", "2012-12-04 13:40:08",
"2012-12-04 14:39:24", "2012-12-04 16:04:25", "2012-12-05 06:02:17",
"2015-05-08 10:00:58"), sender = c(1L, 1L, 1L, 2L, 1L, 1L), message = c("Hello handsome!",
"\U0001f618", "\U0001f603", "<image omitted>", "Haha not white and blue... White with blue eyes \U0001f61c",
"\U0001f631\U0001f637")), .Names = c("time", "sender", "message"
), class = "data.frame", row.names = c("1", "2", "3", "4", "73",
"40619"))
【问题讨论】: