【发布时间】:2016-11-14 17:05:14
【问题描述】:
我有一个字符(文本)列:
tweets <- c(
"Drinking a Bud Light by @Budweiser @ Joe's Crab Shack http://www.joes.com",
"Drinking a Sam Adams Winter Ale by @SamAdams @ Growler Stop http://www.growlerstop.com",
"Drinking a Coco Loco by @NoDaBrewing @ The Corner Pub http://www.cornerpub.com"
)
如您所见,假设推文具有标准结构:
"Drinking a [name of beer] by @[name of brewery] @ [name of bar, notice whitespace] http://"
我想使用正则表达式(和substr()?)来创建三个新列:
- 啤酒名称
- 啤酒厂名称
- 栏的名称(注意可能有空格,所以需要转到“http:”)
更进一步 - 我如何控制一些结构不同的推文?
【问题讨论】: