【发布时间】:2019-12-04 11:59:20
【问题描述】:
考虑以下data.frame:
df <- data.frame(ID = 1:2, Location = c("Love, Love, Singapore, Love, Europe, United States, Japan, Amazon, Seattle, Orchard Road, Love",
"Singapore, Singapore, Singapore") , stringsAsFactors = FALSE)
我想从上面提到的 df$Location 列中找出唯一数据,即我想获得一个新列,它只包含唯一的位置名称,就像下面提供的数据框一样;
df <- data.frame(ID = 1:2, Location = c("Love, Love, Singapore, Love, Europe, United States, Japan, Amazon, Seattle, Orchard Road, Love",
"Singapore, Singapore, Singapore") ,
Unique.Location = c("Love, Singapore, Europe, United States, Japan, Amazon, Seattle, Orchard Road",
"Singapore"), stringsAsFactors = FALSE)
任何输入都会非常明显。
【问题讨论】: