【发布时间】:2021-01-20 07:09:12
【问题描述】:
我有一个数据集,应该清理它。我的数据中的一个例子:
new<-"\\nLocation:\\nMy home is conveniently located around the corner from the Galleria Mall. There's an abundance of food options in every direction of my place. There are also 2 movie theaters within 5 minute driving distance. Addison which is known for their restaurants and nightlife is a 5 minute drive.\\n-DFW ; Lovefield Airport 20min\\n-American Airlines Center 15min\\n-Downtown 15min\\n-Deep Ellum, Lower Greenville, Uptown 20min"
我尝试使用这个功能:
str_replace_all(new, "[\n]", "")
但它不起作用。
我的问题:
- \n 和 \\n 有什么区别
- 如何删除?
【问题讨论】:
-
1.) 要了解区别,请将
cat("\n")与cat("\\n")进行比较。当这些被传递给正则表达式引擎时,也会发生同样的情况。
标签: r data-cleaning