matching

Matching based on different independent tables using data.table in R

落花浮王杯 提交于 2021-01-01 09:07:52
问题 I would like to match multiple conditions from independent data tables onto my main data table. How can I do this using the data.table package? What would be the most efficient/fastest way? I have a mock example, with some mock conditions here to illustrate my question: main_data <- data.frame( pnum = c(1,2,3,4,5,6,7,8,9,10), age = c(24,35,43,34,55,24,36,43,34,54), gender = c("f","m","f","f","m","f","m","f","f","m")) data_1 <- data.frame( pnum = c(1,4,5,8,9), value_data_1 = c(1, 2, 1, 1, 1),

Regex match ordering

只谈情不闲聊 提交于 2020-12-31 05:29:42
问题 My question is simple suppose I would like to match the vowels in a word, but I would like to match them in a specific order as the appear such as a, e, i, o, u. How would I go about doing this? 回答1: So you're looking for a followed by some characters, then e followed by some characters, and so forth? In other words, a followed by stuff that isn't e , then e . Then stuff that isn't i then i . Then stuff that isn't o then o . And finally stuff that isn't u and lastly a u . In regexp terms,

Regex match ordering

≡放荡痞女 提交于 2020-12-31 05:28:19
问题 My question is simple suppose I would like to match the vowels in a word, but I would like to match them in a specific order as the appear such as a, e, i, o, u. How would I go about doing this? 回答1: So you're looking for a followed by some characters, then e followed by some characters, and so forth? In other words, a followed by stuff that isn't e , then e . Then stuff that isn't i then i . Then stuff that isn't o then o . And finally stuff that isn't u and lastly a u . In regexp terms,

Do not merge the context of contiguous matches with grep

China☆狼群 提交于 2020-12-08 05:46:09
问题 If I run grep -C 1 match over the following file: a b match1 c d e match2 f match3 g I get the following output: b match1 c -- e match2 f match3 g As you can see, since the context around the contiguous matches "match2" and "match3" overlap, they are merged. However, I would prefer to get one context description for each match, possibly duplicating lines from the input in the context reporting. In this case, what I would like is: b match1 c -- e match2 f -- f match3 g What would be the best

Do not merge the context of contiguous matches with grep

孤街醉人 提交于 2020-12-08 05:46:04
问题 If I run grep -C 1 match over the following file: a b match1 c d e match2 f match3 g I get the following output: b match1 c -- e match2 f match3 g As you can see, since the context around the contiguous matches "match2" and "match3" overlap, they are merged. However, I would prefer to get one context description for each match, possibly duplicating lines from the input in the context reporting. In this case, what I would like is: b match1 c -- e match2 f -- f match3 g What would be the best