« first day (209 days earlier)      last day (3314 days later) » 
00:00 - 17:0017:00 - 00:00

17:00
@Tensibai i'm saying: just skip creation of Col_4
@Frank awww, ok, get it
the basic operation is increasing Col_3 by a percentage determined in Col_1 and a value in Col_2. Col_4 was just an intermediate object created to assist in updating Col_3
wish they'd picked better names...
yep
Let's see if I get it, when you encouter a Col_2=="A", take the actual value of Col_3 and multiply it by 1+Col_1
for col_2 != "A" take previous value
Aww, even worse according to desired output, that's the next line which is incremented
yeah, just going to post some concise code for doing it right. hopefully of benefit to the OP: mydata.table[, 1000*cumprod(1+Col_1*shift(Col_2=="A", type="lag", fill=FALSE))]
@user3740289 Fyi, to get your desired output try skipping creation of the intermediate object Col_4 and just doing mydata.table[, Col_3*cumprod(1+Col_1*shift(Col_2=="A", type="lag", fill=FALSE))] (I'm ignoring your issues with get covered by Arun; as well as your overwriting of Col_3.) To understand how this works, try ?cumprod and ?shift. — Frank 1 min ago
(in case it wasn't clear what i meant)
Quick question, how would you output below chr vector

c("1 2 3 4 5",
"1 2 3 4 5",
"1 2 3 4 5")


to a file as:
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
trying to avoid strsplit
17:13
I'm pretty sure write allow this
why avoid strsplit? most printing rules will go by row... i would do print(setDF(strsplit(x," ")), row.names=FALSE) or similar (i'm not very handy with R's I/O functions)
data.frame works in place of setDF, i guess
@Tensibai am I missing something obvious?
@zx8754 I'm searching
My memory may be deficient
@Tensibai I am probably asking for impossible. I want to avoid strsplit and loops :)
17:22
the characters in a file are ordered (left to right, row by row) and so are the characters in your vector. i'd be surprised to hear that there's some way to print to a file in some other order than how the chars are in your vector... could do some substr shenanigans if you really hate strsplit, i guess
given the regular spacing you've got
@Tensibai ah, so that's where flodel is now. haven't seen answers from him/her in the r tag in a long while
@zx8754 with x being your vector: write(as.matrix(read.table(text=paste(x,sep="\n"))),"",3)
2
replace "" by your file name
(I'm kind of worried about the perf of this)
Alternative: write(unlist(read.table(text=paste(x,sep="\n"))),"",3)
@Tensibai bravo, i am befuddled
Thanks
@Tensibai This is brilliant
Highly inspired by flodel code golf
17:32
write(x, file = "data",
ncolumns = if(is.character(x)) 1 else 5,
append = FALSE, sep = " ")
default ncolumns....
1 else 5?
if char, 1 column 'as you'll have a string to print
else print on 5 columns for numeric entries
trying to figure out how this works.... identical(x, paste(x, sep="\n")) # TRUE so i guess you can simplify that
@Frank as I use the text representation for read.table, I see no other way, but I may be wrong
@Frank you're right
read.table(text=x) would do the same
write(unlist(read.table(text=x)),"",3) sounds the best options
yeah
Unsure of which is quicker between unlist and as.matrix
17:37
not sure, i'd bet they're similar. as.matrix just takes the extra step of assigning a dim attribute (and maybe further overheard)
Unit: microseconds
                                          expr     min       lq     mean   median      uq      max neval
 write(as.matrix(read.table(text = x)), "", 3) 707.306 734.9585 797.0310 761.8995 792.547 1469.917   100
    write(unlist(read.table(text = x)), "", 3) 661.406 688.2050 784.5385 712.5800 779.718 2393.032   100
advantage to unlist for this small vector
real data is 4000x100000
ouch
4000 element character string, each has 100000 space delimiters
17:40
Unit: milliseconds
expr min lq mean median uq max neval
write(as.matrix(read.table(text = z)), "", 3) 437.6505 438.1378 438.3676 438.6252 438.7261 438.8270 3
write(unlist(read.table(text = z)), "", 3) 446.7553 451.3071 458.5912 455.8588 464.5091 473.1594 3
For the same 5 chars x 4500 entries
Thank you @Tensibai @Frank
write() is my new best friend.
np, interesting problem and i learned something
Advantage to as.matrix as far I can tell for now :p
17:43
@Tensibai yes I am getting the same result, as.matrix is slightly faster
Well, it takes the df structure near as-is and simplify it
Ok, time to head back home
oh one other idea, from splitstackshape:
    DT = setDT(as.list(x))
    cSplit(DT, names(DT), " ", "long")

   V1 V2 V3
1:  1  1  1
2:  2  2  2
3:  3  3  3
4:  4  4  4
5:  5  5  5
i don't know its internals so can't really guess about performance
cya, @Tens
@Tensibai agreed. A mess, indeed.
anyone have a dupe for "don't use eval/assign/et al"? stackoverflow.com/q/33763689/1191259
@Arun okay, so now we can close as a typo, eh?
You were right @Frank I've updated the package version and the code you provided works perfectly. Thanks very much — user3740289 1 min ago
18:01
@Frank it's even more weird to close it as a typo now.. :-). God.. what a mess! It's a completely different (and very nice) answer (from you) instead.. Perhaps you should post it so that he can accept, and then we all forget it ever happened!
I hate the fact that it wasted everyone's time..!
yeah
posted, dunno that that's better than closing, but... eh, might as well
18:39
hm, op has now updated the q... not sure the reason
19:32
@Jaap @DavidArenburg remember I had those interviews last week
@Frank havnt we discussed this extensively?
And said I didn't get it? They called back! How weird. I feel like someone's playing tricks
@PierreLafortune no \hides
@PierreLafortune so did you get it?
They made an offer. I'll negotiate and close the deal :)
hoah
guess someone bailed at the last minute
19:33
@DavidArenburg my memory is shot, so probably
@PierreLafortune cool, congrats!
Thank you
I told my current boss to match. I'll wait to hear back
oh, that cruel :)
I like\
:) check this out lol medium.com/@oceankidbilly/…
Funny but he doesn't get R subsetting right :)
yeah, looks like gibberish with no correspondence even with the python code
@PierreLafortune wow, congrats man!
19:42
Thanks!
what kind of job is it?
suppose that your current boss matches, what do you do then?
It's a data scientist position with a large company.
@PierreLafortune saw that some time ago, was annoyed by the sloppy use of R
guess the whole post is an in-joke with others who regard python and r as "hot" languages
Also to stop the comparison argument.
fruitless debate
19:47
eh, i think the discussion of pros-cons is legitimate, but agree that what the code looks like is a secondary issue between r and python
@Jaap I would consider staying
@PierreLafortune your current job is in educational research isn't it?
Yes. It's not that bad. And I like my coworkers and office
@PierreLafortune which(sapply(df, function(x) any(month == "January"))) - really?
lol I know
It doesn't even make sense.
R:
x[1]
Python:
x.iloc[1]
in Python you start at 0. so that's off there. And .iloc returns rows in that way.
19:57
i guess part of the joke is "people who think they are qualified to make these comparisons often are not"
@Frank too deep for me, I would classify that post as rubbish
mee too
@PierreLafortune congrats, I would ask to match and beat - yearly bonus, new PC, new chair/desk/socks...
@zx8754 not saying i disagree :) just trying to guess what the op thought was funny in it
@zx8754 haha lots of perks there
20:00
don't forget a company limo
@Frank probably that would push the boss to use f words
I think the equivalent of df[1] is df.iloc[:,0]
off topic: do you guys check the rating of a movie IMDB, rottentomatoes, etc, before deciding to watch it?
nope
@zx8754 sometimes. I watched this one yesterday. It was horrible. high reviews rottentomatoes.com/m/spy_2015
@PierreLafortune I gave up on this one in 10 mins - rottentomatoes.com/m/twinsters
@Jaap "Also COBOL seems like it was designed for angry ppl (all those CAPS :-)" nice
@zx8754 oh, and the boss's parking spot
Gotta get this work done before 5. later all!
@zx8754 yeah, i like using rotten tomatoes. there are places where i disagree with the consensus, but i know them ahead of time (any brad bird project, for example, is awful)
20:12
@PierreLafortune you can't let your boss down now you've asked for a raise ;-)
@MichaelChirico edited your answer because using "!" in front ew gives the desired result
furthermore, I think your second solution is not what OP wants
@Jaap if by "gives the desired result" you mean that you have tested with the op's data, maybe you could put the dput into the q or a..?
anyway dt[ nchar(V2) > 5 ][ !( V2 %chin% ew$V1 ) ] should do it, i guess
the example's pretty terrible, since the second criterion is never used...
yep, tested it on op's data
@Frank then dt[ nchar(V2) > 5 & !( V2 %chin% ew$V1 ) ] should also work
20:28
@Jaap yeah, maybe fewer computations sequentially, if one of the criteria drops a lot of obs. could you add the dput?
anyway, Michael's first way looks good, now that it has the !. could just remove the second one
or rewrite it so that the nchar comparison comes first
added the dput's; no time left, have to go
ok, thanks. cya Jaap
 
2 hours later…
22:03
destroy
0
A: Remove rows with NAs in data.frame

Benoit B.Well I have found this (my DF if called final) > t = final[!(is.na(final[,2:6]) ),] > head(t) gene hsap mmul mmus rnor cfam 1 ENSG00000208234 0 NA NA NA NA 2 ENSG00000199674 0 NA NA NA NA 3 ENSG00000221622 0 NA NA NA NA 4 ENSG00000207604 0 NA ...

Wut?
0
Q: Sample-based rarefaction in R

escapecraneI am hoping to perform a sample-based rarefaction using the vegan package. I have 30 gardens that I sampled 4 or 5 times. I want to use the sample number as the basis of the rarefaction, but all the tutorials I have seen use individual number. I need to know how to group the data and the approp...

23:01
@StevenBeaupré - that's why I don't answer dplyr Qs any more. Haha
Too many ways to get the same result
I've never used dplyr::rename
Why delete ?
bramatyl never rests Id tell you that
Yeah this guy is intense
23:04
@RichardScriven last DV here pls stackoverflow.com/questions/4862178/…
DV'ed already
@DavidArenburg hey, is there a way to tell who has already delete-voted?
@StevenBeaupré I need the DV that makes things to disapear :)
@Frank no, but Rich just came here, no?
@Frank did you cast a vote?
yeah
23:06
thought you found some page listing it. there are all sorts of weird hidden pages
like posts/[postnumber]/revisions
@StevenBeaupré I just don't have the energy to deal with the impending commentary. Haha
surpised this survived so many years without a flag/DV and a Delete vote
@RichardScriven Can you believe bramatyl just stole my comment and posted an answer :o
He might not have seen it though. I deleted quickly after your comment
Oh, right.
23:08
I'm kinda shocked that he didn't reshape the data though
"To change the column names, we can do a cross-join"
4
Haha
@RichardScriven Konrad dupe just sums it up
I saw him doing something like this not long ago "Y ~ X" %>% lm(.) %>% summary(.)
Why-o-why use rename NSE
Does Konrad not have the R hammer?
Please close
23:11
MC Dupehammer
Maybe I'll have one of those, one day..
@RichardScriven no, he is working very hard on it though
@StevenBeaupré you will have it very soon
Woah josilber is on fire
yeah
though i think his answers are not so highly upvoted
though an R mod active during the GMT hours could be useful
it could be good to have him here
I think his answers don't always appeal to a broad audience
23:19
he's east-coast US, eh, not quite gmt, depending on how early he gets up. i really haven't noticed him around (answering questions and such) for a while
i think he is active many hours
like I am
heh, indeed
he does moderation most of his time
i mean he has 8e3 flags
@StevenBeaupré talking about his answers to the mod questionnaire (not sure if you mean his SO answers)
Most probably, judging by the number of flags
23:20
the answers seemed pretty mainstream to me
@Frank Oh, haven't had the chance to read his answers to the mod questionnaire. I was talking about his answers on SO
ok
lol 8e3
always coding
actually 8.5e3 but who counts
19
Q: What number does 8e3 evaluate to?

ToastI encountered this code today: b = setTimeout(function () { // do some javascript stuff here }, 8e3) The timeout is set to 8e3. What time does this equate to in milliseconds, and why would anyone choose this strange notation? The code appears to be fully functional.

Someone asked that question...
weird coincidence :)
@zx8754 I'd guess you found it cause you were wondering yourself :)
I bet it would get a couple of votes if asked in the R tag today
@DavidArenburg nope :)
finally an old question with multiple identical answers posted at the same time
23:31
Flag 'em all
hah
not like our old questions with 1e4 idnetical answers posted with a year difference from each other
and all with 1e2+ upvotes
.. why would anyone choose this strange notation?
I had to put it here after Richards comment :)
NO I will NOT change my name. Wtf people
23:49
So facebook is shutting down all accounts for people named "Isis"? Haha
Sucks for them
Isis should be called "Bunch of Asshole Prickbags", or BOAP for short
3
00:00 - 17:0017:00 - 00:00

« first day (209 days earlier)      last day (3314 days later) »