agrep
に一致seconds
させようとしてsecond
いますが、これを達成するための値はない millisecond
ようです。costs
deletions
/のコストの価値がないことは特に混乱していinsertions
ます。これはトリックを行うようです-私が見るように、second
削除は 1 回ですが、seconds
削除millisecond
は 1 回で、挿入は 5 回です。
(しばらく時間がかかる場合があることを警告しlapply
ます...同じ結果が得られlength.out = 10
、0:10
はるかに速くなります)
rng = c(seq(0, 1, length.out = 20), 0:100)
x = expand.grid(insertions = rng, substitutions = rng, deletions = rng)
units = c("millisecond", "second", "minute", "hour", "day",
"week", "month", "quarter", "year")
x$match = lapply(seq_len(nrow(x)), function(ii)
agrep('second', units, value = TRUE, costs = x[ii, ]))
x$match_which = sapply(x$match, paste, collapse = '|')
sort(table(x$match_which))
# millisecond|second|minute|hour|week|month|year
# 57
# millisecond|second|minute|hour|week|month|quarter|year
# 13276
# millisecond|second|month
# 23316
# millisecond|second|minute|month|quarter
# 37842
# millisecond|second|minute|quarter
# 251480
# millisecond|second|minute|hour|day|week|month|quarter|year
# 409865
# millisecond|second
# 1035725
ここで何が欠けていますか?で私のタスクを達成する方法はありませんか ( と一致seconds
しsecond
ないmillisecond
) agrep
?