agrep insists on matching millisecond (and not just second)Aggregate by year and month for a POSIX variableissue with agrepHow does agrep matching work?agrep string matching in RR lubridate, Calculate Age including Leap YearsWhy does agrep in R not find the best match?Construct a loop to compare two dataframes and fill the missing valuesfuzzy string matching with agrep()ggplot2 axis for time durations on a log-like scaleConvert H2OFrame object from milliseconds to Minutes?
Why does putting a dot after the URL remove login information?
Why do implementations of "stdint.h" disagree on the definition of UINT8_C?
Beta value of the thermistor
Is it really ~648.69 km/s Delta-V to "Land" on the Surface of the Sun?
Did WWII Japanese soldiers engage in cannibalism of their enemies?
How can I tell if a flight itinerary is fake
Secure my password from unsafe servers
Short story about a teenager who has his brain replaced with a microchip (Psychological Horror)
Capacitors with a "/" on schematic
How to avoid ci-driven development..?
Do other countries guarantee freedoms that the United States does not have?
What can make Linux unresponsive for minutes when browsing certain websites?
What word can be used to describe a bug in a movie?
WordCloud: do not eliminate duplicates
Did Apollo leave poop on the moon?
How to realistically deal with a shield user?
Why couldn't soldiers sight their own weapons without officers' orders?
How quickly could a country build a tall concrete wall around a city?
Traveling from Germany to other countries by train?
Need help understanding lens reach
Why do private jets such as Gulfstream fly higher than other civilian jets?
In what sense are the equations of motion conserved by symmetries?
Why should I "believe in" weak solutions to PDEs?
Does the Voyager team use a wrapper (Fortran(77?) to Python) to transmit current commands?
agrep insists on matching millisecond (and not just second)
Aggregate by year and month for a POSIX variableissue with agrepHow does agrep matching work?agrep string matching in RR lubridate, Calculate Age including Leap YearsWhy does agrep in R not find the best match?Construct a loop to compare two dataframes and fill the missing valuesfuzzy string matching with agrep()ggplot2 axis for time durations on a log-like scaleConvert H2OFrame object from milliseconds to Minutes?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to get agrep
to match seconds
to second
and not millisecond
, but there doesn't seem to be any value of costs
to accomplish this.
I am especially confused that there's no value of the cost for deletions
/insertions
that seems to do the trick -- as I see it, second
is one deletion from seconds
whereas millisecond
is one deletion and 5 insertions.
(warning that the lapply
might take a while... you would get the same result for length.out = 10
and 0:10
much quicker)
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
What am I missing here? Is there no way to accomplish my task (match seconds
to second
and not millisecond
) with agrep
?
r agrep
add a comment |
I'm trying to get agrep
to match seconds
to second
and not millisecond
, but there doesn't seem to be any value of costs
to accomplish this.
I am especially confused that there's no value of the cost for deletions
/insertions
that seems to do the trick -- as I see it, second
is one deletion from seconds
whereas millisecond
is one deletion and 5 insertions.
(warning that the lapply
might take a while... you would get the same result for length.out = 10
and 0:10
much quicker)
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
What am I missing here? Is there no way to accomplish my task (match seconds
to second
and not millisecond
) with agrep
?
r agrep
I might be off, but does it help to doagrep("^second", ...)
to make sure the matched pattern starts with"second"
?
– Lennyy
Mar 27 at 6:26
@Lennyy could be... but would needfixed = FALSE
to do regex matching... still not sure why it wouldn't work withfixed = TRUE
– MichaelChirico
Mar 27 at 8:40
add a comment |
I'm trying to get agrep
to match seconds
to second
and not millisecond
, but there doesn't seem to be any value of costs
to accomplish this.
I am especially confused that there's no value of the cost for deletions
/insertions
that seems to do the trick -- as I see it, second
is one deletion from seconds
whereas millisecond
is one deletion and 5 insertions.
(warning that the lapply
might take a while... you would get the same result for length.out = 10
and 0:10
much quicker)
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
What am I missing here? Is there no way to accomplish my task (match seconds
to second
and not millisecond
) with agrep
?
r agrep
I'm trying to get agrep
to match seconds
to second
and not millisecond
, but there doesn't seem to be any value of costs
to accomplish this.
I am especially confused that there's no value of the cost for deletions
/insertions
that seems to do the trick -- as I see it, second
is one deletion from seconds
whereas millisecond
is one deletion and 5 insertions.
(warning that the lapply
might take a while... you would get the same result for length.out = 10
and 0:10
much quicker)
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
What am I missing here? Is there no way to accomplish my task (match seconds
to second
and not millisecond
) with agrep
?
r agrep
r agrep
asked Mar 27 at 6:02
MichaelChiricoMichaelChirico
21.7k8 gold badges66 silver badges126 bronze badges
21.7k8 gold badges66 silver badges126 bronze badges
I might be off, but does it help to doagrep("^second", ...)
to make sure the matched pattern starts with"second"
?
– Lennyy
Mar 27 at 6:26
@Lennyy could be... but would needfixed = FALSE
to do regex matching... still not sure why it wouldn't work withfixed = TRUE
– MichaelChirico
Mar 27 at 8:40
add a comment |
I might be off, but does it help to doagrep("^second", ...)
to make sure the matched pattern starts with"second"
?
– Lennyy
Mar 27 at 6:26
@Lennyy could be... but would needfixed = FALSE
to do regex matching... still not sure why it wouldn't work withfixed = TRUE
– MichaelChirico
Mar 27 at 8:40
I might be off, but does it help to do
agrep("^second", ...)
to make sure the matched pattern starts with "second"
?– Lennyy
Mar 27 at 6:26
I might be off, but does it help to do
agrep("^second", ...)
to make sure the matched pattern starts with "second"
?– Lennyy
Mar 27 at 6:26
@Lennyy could be... but would need
fixed = FALSE
to do regex matching... still not sure why it wouldn't work with fixed = TRUE
– MichaelChirico
Mar 27 at 8:40
@Lennyy could be... but would need
fixed = FALSE
to do regex matching... still not sure why it wouldn't work with fixed = TRUE
– MichaelChirico
Mar 27 at 8:40
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370732%2fagrep-insists-on-matching-millisecond-and-not-just-second%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370732%2fagrep-insists-on-matching-millisecond-and-not-just-second%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I might be off, but does it help to do
agrep("^second", ...)
to make sure the matched pattern starts with"second"
?– Lennyy
Mar 27 at 6:26
@Lennyy could be... but would need
fixed = FALSE
to do regex matching... still not sure why it wouldn't work withfixed = TRUE
– MichaelChirico
Mar 27 at 8:40