С data.table
вы можете сделать:
library("data.table")
df1 <- fread(
"Syllable Duration Pitch
@ 0.08 93
@ 0.05 107
@ 0.13 56
@ 0.07 95
@ 0.07 123")
df2 <- fread(
"Syllable Duration
@ 0.08
@ 0.05
@ 0.07
@ 0.07")
merge(df1, unique(df2))
# > merge(df1, unique(df2))
# Syllable Duration Pitch
# 1: @ 0.05 107
# 2: @ 0.07 95
# 3: @ 0.07 123
# 4: @ 0.08 93
или без сортировки:
merge(df1, unique(df2), sort=FALSE)
# > merge(df1, unique(df2), sort=FALSE)
# Syllable Duration Pitch
# 1: @ 0.08 93
# 2: @ 0.05 107
# 3: @ 0.07 95
# 4: @ 0.07 123
этот последний аналогичен:
df1[unique(df2), on=c("Syllable", "Duration")]
# > df1[unique(df2), on=c("Syllable", "Duration")]
# Syllable Duration Pitch
# 1: @ 0.08 93
# 2: @ 0.05 107
# 3: @ 0.07 95
# 4: @ 0.07 123
Сбаза R
:
df1 <- read.table(header=TRUE, text=
"Syllable Duration Pitch
@ 0.08 93
@ 0.05 107
@ 0.13 56
@ 0.07 95
@ 0.07 123")
df2 <- read.table(header=TRUE, text=
"Syllable Duration
@ 0.08
@ 0.05
@ 0.07
@ 0.07 ")
merge(df1, unique(df2))
merge(df1, unique(df2), sort=FALSE)