我正在尝试使用 R 来分析下载的一些 Facebook 消息。一些消息将撇号替换为“â” - 我正在尝试使用 str_replace_all() 替换它。
举个例子,下面的data.table
names <- c("Me", "Me", "You", "You", "Me", "You")
content <- c("Iâ<U+0080><U+0099>ve got my party on the 5th", "Hello", "Bears", "Four times four", "what do you want to eat?", "get some music")
date <- c("1/1/2001", "2/1/2001", "3/1/2001", "4/1/2001", "5/1/2001", "6/1/2001")
fbmessagesexample <- data.table(names, date, content)
然后我尝试使用 str_replace_all
fbmessagesexample[, content := str_replace_all(content, pattern = fixed("â<U\\+0080><U\\+0099>"), replacement=fixed("'"))]
内容中的第一行没有被替换。有什么我做错了吗?