« first day (2840 days earlier)      last day (462 days later) » 

7:46 AM
Good morning
 
Hi all :)
 
One downside is that packages can mask functions from other packages or even base R. Hadley in particular is known to have no compunction against doing that with his packages. — Roland Jul 11, 2017 at 10:29
new word of the day - "compunction - a feeling of guilt or moral scruple that prevents or follows the doing of something bad."
3
 
8:28 AM
last vote re-open, op added repro data - stackoverflow.com/q/75278297/680068
 
done
 
8:43 AM
hello @ all :-)
 
9:28 AM
 
@Cath nice find, post as comment/answer
 
@zx8754 posted as comment
 
9:56 AM
@zx8754 I wonder how I found that word. Maybe by translating the beautiful German word "Gewissensbisse"? dict.leo.org/englisch-deutsch/Gewissensbisse
 
10:19 AM
@Roland lovely: "pricks of conscience"
 
 
2 hours later…
12:44 PM
Does anyone know if grep("(x)", vec) should return something magical?
 
1:05 PM
@RomanLuštrik what is the input and expected output?
 
1:16 PM
Just a matrix (vector) with a few cells with some text. Can't say more about the text because I didn't see the full rainbow of entries.
But if I understand correctly, it should return a match if there is an x, right?
 
1:29 PM
@RomanLuštrik Well, dunno if it's magical, but it returns the index of entries matching x in vec
with vec <- ['a', 'b', 'c', 'x', 'y'] it should return 4 for exemple
 
1:47 PM
Right, that's what I figured.
Oh well. :) Thanks.
 
1:58 PM
@RomanLuštrik Forgot to say there's value=TRUE to get the values matching instead of just the index
 
@Tensibai so what is () doing here? grep("x", vec) would give 4 too?
 
yes, the parentheses are for a regex to make a group
(more useful with regexpr and regmatches, but grep and gsub takes a regex too as first parameter)
 
AFAIK the parentheses are moot in grep. Perhaps @Cath has more info on it, being the regex master in this group.
 
2:14 PM
Yep, useless in grep, a bit dangerous when you really want to match a parenthese
 
As a regex noob, I always use fixed = TRUE :D
 
2:33 PM
@RomanLuštrik lol (but thanks :) ), if you want a T/F use grepl, if you want the indices, use grep if you want the values use grep with value=TRUE (I'm aware it's already been said ^^). For the parentheses, I'd say useless here but might be useful if you search for a repeated pattern
e.g. of useful parentheses: grep("(.{2})\\1", c("toto", "tota"), value=TRUE)
 
@Cath just guessing... any 2 letters repeated?
 
yep
sorry I didn't clarify
 
@zx8754 not sure if its faster, but I would o it like this with data.table:
setDT(df)

for (cc in cols) {
  df[, (cc) := rowMeans(.SD), .SDcols = grep(cc, names(df))]
}

df[, ..cols]
 
@zx8754 or more like two anything repeated (not just letters)
 
2:58 PM
Sure. But my code chunk there had no sense with the (x). Going through a script of 3k lines and there are wonders like that in there.
 
old code or someone else's code?
 
Third party code. Package versions unknown.
 
:(
take it as a game ^^
 

« first day (2840 days earlier)      last day (462 days later) »