« first day (630 days earlier)      last day (2893 days later) » 

07:15
Goooood morning people ! !
07:48
hello @Sotos & @germcd :-)
@Queen k
@Queen k
Hello everyone :-)
08:23
Question. Assume x <-c(1,2,5,2,3). Now I want to add the values that are the same so I used sapply(unique(x), function(i) sum(x[x == i])) which gives 1 4 5 3. Any way I can get it to add them in second position? i.e. to get result 1 5 4 3?
Good morning!
@Sotos What about x <- rev(x) and then repeat with reverse?
@Sotos sapply(x[!duplicated(x, fromLast = TRUE)], function(i) sum(x[x == i]))
@Sotos sapply(unique(x, fromLast = T), function(i) sum(x[x == i]))
Yup...all of the above :)
@RonakShah nice! didn't know that unique also had a fromLast argument
08:32
Thank you @Jaap @RonakShah @m0nhawk :)
btw @RonakShah it is better to use TRUE than T ;-)
@Sotos My solution is inefficient. Forget about fromLast. :)
Well I ended up using Ronaks as I already had the unique in there so just added the fromlast part...which I too did not know it is also provided for unique function
@m0nhawk rev was my initial thought as wel ;-) then thought about fromLast from duplicated; but I think unique with fromlast will be the most succinct one
Hello
08:38
@Jaap Thanks! so many times people have told me that but somehow the lazy monster in me always end up with T, F..
@RonakShah you too have a lazy monster? Procrastinating FTW :)
@Jaap And what wrong with T/F?
Hello
Hiya @zx8754
08:47
@m0nhawk a partial answer:
16
Q: Is there anything wrong with using T and F instead of TRUE and FALSE?

Rob I noticed that using T and F instead of TRUE and FALSE in functions in R gives me the same results. Of course, T and F are more concise, yet, I see TRUE and FALSE being used more often. I was wondering whether there is any difference between the two? Is there anything wrong with using T and F?

@m0nhawk The fact they can be overridden by antyhing
So you may end up with something a variable named F which doesn't mean FALSE.
> F<-c(1,3); T & F
[1] TRUE TRUE
> TRUE & FALSE
[1] FALSE
But as stated above, nothing wrong to use them interactively, just don't rely on it in code to avoid being hit by another part of code somewhere.
@m0nhawk interesting, but it comes with a pretty hefty price tag :-/
09:09
Never though that the T and F can be redefined.
09:27
Any headphones that pause the music when you take them off from your ears?
@zx8754 no idea but brilliant!
@zx8754 On a mobile or PC?
at work on pc
a bit painful to switch from whatever you working on to find the tab with music on and pause
Mine pause the music when I unplug the headphone from the device
(on android, I think I've something darklaunched to do the same on windows, let me check)
I think it's the sound card driver which handle this
This maybe due to sounds card or a music player.
Mine doesn't pause with VLC.
09:41
@Tensibai yes, heard about unplug, but I just want to put them down on my desk. #firstworldproblems
Rofl, I see no way then :)
Maybe add gyroscope in headphones :p
But I d definetely buy such headphones
@Sotos @zx8754 Exists:
and a sensor pauses the music every time you take them off your head.

Read more: http://www.dailymail.co.uk/home/moslive/article-2189255/Starcks-Zik-headphones-Are-Starck-raving-mad-The-headphones-pause-music-head.html#ixzz4VRjAUy8J
Follow us: @MailOnline on Twitter | DailyMail on Facebook
Can't get the english version of the parrot.com page
but well: parrot.com => audio
@Tensibai nice find thanks, it is from 2012, so there must be others
10:18
@Tensibai cheers, noted for my bday and xmas wishes :)
@Natty tp
@Natty tp
@Tensibai could use one of those at work :-)
10:39
@Tensibai awesome!!!
I wonder how well do they cancel gun fire...? :)
11:30
@Queen k
12:47
@zx8754 Looks like yes to me.
@Axeman cheers gone.
@Natty tp
 
2 hours later…
@Sotos probably a new 'friend'
@Queen k
@Jaap yup. I can feel the love
your solution works
anyway, added a pure base R solution as wel
Is the link I commented here a dupe?
@Jaap I was trying to add a baseR too but got lost in regex (last comma) and gave up :p
regex isn't the answer to everything ;-)
15:18
I know and I suck too :) but I try to use it as much as possible to master them.
then we can shake hands: I suck too at regex ;-)
2
15:43
is this really a bug? i wouldn't have expected by= to work with get() stackoverflow.com/q/41586752
@Queen k
16:44
@DavidArenburg I'm confused. I'm summing over a logical vector to count the number of TRUEs. I'm happy to hear alternatives, but I'm not sure what your suggestion is?
I feel like I'm missing something obvious..
And what's wrong with the sum?
If anyone interested in job prospects, here is my ex-colleague looking for a Full Time Data scientist twitter.com/m_barrett/status/818865570112278528
@Jaap I know I have to learn it, but still managing to get by with sapplys and strsplits :)
I know some basics
my knowledge about regex is improving (very) slowly though
17:00
And I like regex.
Pretty nice tool to solve some problems.
 
1 hour later…
19:16
@Axeman I just meant this
x <- sample(0:1, 10, replace = TRUE)
sum(x) == sum(x[x == 1])
## [1] TRUE
But I don't have purr installed and I probably just misreading your code as its syntax looks like jibrish to me
@DavidArenburg Sure, I don't think that that was what I was doing though.
@DavidArenburg Yes, in this case it is actually especially obtuse.
map(date, ~sum(x == 1 & between(date, . + 1, . + 14)) is equivalent to lapply(date, function(d) sum(x == 1 & between(date, d + 1, d + 14)) } )
Ok, you are basically summing a logical vector
so what is the advantage of using map over lapply? That you don't need to specify anonymous functions?
19:32
in avoiding specifying an anonymous function, you also don't have to think what varname to use (d here), i guess. maybe improves readability if you're used to it...
@Queen k
@DavidArenburg Really not all that much. It's nice to directly index things, such as map(x, 1) to take the first element of all list items. I find it a bit quicker to write. and I slightly prefer the logic of using map2 and map_n over Map or mapply, and map_dbl etc over sapply, since they all work similarly and are named similarly so it is easy to quickly correct yourself.
ok
I kind of feel like it is an overkill to load packages just in order to do a simple lapply and having to memorize new function too. I never had problems wit those functions so I dont see the point
I like to use packages when they offer something R devs haven't developed or developed in-efficiently
Sure, I see your point.
20:07
I also feel like Hadley trying really hard overriding pretty much any functions ever written in R
nowdays, when a new useR reads several answers on the same question he thinks they were written in different languages
True. At work, I deal a lot with quite novice R users, and they do often seem to pick up the 'tidy' solutions a bit quicker than base though. Which saves me time.
@DavidArenburg he works in Rstudio. So this looks like some library-lock-in. As long as hadleyverse is free and open sourced - there is no problems with it.
close as repro or it didn't happen stackoverflow.com/q/41597843
@m0nhawk Not sure what you trying to say. I'm actually fine with it not being free or open source.
Maybe that will make some new users to actually learn R first
@DavidArenburg I mean, that, if Rstudio decided to make hadleyverse non-free it will ruin the existed codebase.
20:15
oh well, the is a lot of data.table answers on Qs that are easily done in base. To each their own.
@m0nhawk There is a ton of github forks, so I guess not?
@Axeman Yes, I agree. As a data.table fun I still always answer with base R when I feel it can be solved efficiently as such
@Axeman True.
data.table is only for heavy artillery. Though I admit that at the beginning of my SO career I was sticking useless data.table answer pretty much anywhere in a desperate attempt to get some rep
I'd like most of hadleyverse to become a part of a base.
@m0nhawk heh, wasn't expecting that was where you were going with your concern about it going non-free. i certainly don't want it in base. the inconsistent naming and overlapping functionality of base functions is bad enough as it is
20:21
^ that
I wouldn't like data.table be part of base R neither
@Frank I mean replacing some functions from base and making consistent naming.
speaking about breaking code base..
@m0nhawk oh, you'd have to make a whole new lang, can't go taking away Map now that i've used it 1000 times
@Frank The Python 3 and PHP 7 have done it so far.
And R have lesser codebase.
Just thoughts. :)
python 2 vs 3 seems like a real s***show, eh (viewing it from outside)
20:24
breaking backward compatibility is the new trend these days
Spark just did the same while switching from 1 to 2
Spark doesn't consider a Vector to be a Vector if it was created by an older version of the ml library
sounds like a good time
@Frank I'm using Python everyday for 3-4 years so far. And that's not a problem. If someone want to use and old code - you can freely use old version. But if the software is constantly updating - stick to old versions isn't good.
@DavidArenburg oh, that sounds unnecessarily breaky
@m0nhawk i want my code to still run in 10+ years. i'm not a software dev with a strong interest in being employed as a code maintainer :)
it's just stats stuff, not like i'm making some sort of web front-end or something...
@Frank Then just make a README with a version of R.
@m0nhawk or lobby r core to keep being backward compatible :)
eventually, i'll have to learn to use docker or one of those other things to bundle in r and package versions
20:30
packrat
yeah, maybe that's what i meant (haven't actually started using any of them yet)
R have poor backward compatibility with packages.
Especially ggplot.
@m0nhawk Well you know who wrote that
Actually, with dplyr and other I wasn't having any major issues.
it's basically all small theme stuff that breaks now and then
20:33
@m0nhawk well, I had some problem with silently masking different base functions
dplyr's only at version 0.5, i don't think you can complain if you run into compatibility issues with it, eh
with each release, it seems like some new function is being masked
now, for instance, setdiff has been overwritten
@DavidArenburg That's a problem, but not with a backward compatibility in R.
I hate that dplyr::select masks MASS::select
@Axeman well that's not Hadleys fault really, cause it's a package vs another package
silently masking base R is kind of evil IMO
20:36
@DavidArenburg And what was wrong with base::setdiff? I bet it's not a speed issues...
@m0nhawk Well, dplyr depreciated many function already. Soon enough summarise_each and mutate_each will lose backward compatibility
@m0nhawk He added a data.frame method or something like that
yeah, probably invalidating a good chunk of SO posts
base::setdiff isn't a generic (or whatever you call it when it can dispatch)
@DavidArenburg At least base functionality is maintained, so it should be fine?
@Axeman Unless he will either stop maintaining it or insert a bug by mistake
By masking base R functions, he basically becomes the maintainer of base R too
@Axeman well, except for cases where you want to treat a DF like a list and do setdiff with that: setdiff(data.frame(a = 1:2, b = 2:3), data.frame(a = 1:2))
20:39
@DavidArenburg Without contributing to R directly.
We don't need no fragmentation.
@Frank Good point.
imo, base R should make it a generic so hadley (and everyone else) can just write a method
He should have just done set_diff, like if_else etc
(and similarly for other set operators)
the problem is that you never know what to expect when loading tidyverse
I'm really surprised why CRAN team allows such packages to be loaded to CRAN
20:42
@DavidArenburg True, I suspect the list loaded packages with library(tidyverse) is also not going to be very stable
@DavidArenburg I don't think they even check the packages on submission.
@m0nhawk I never tried but I heard it's very hard to load a package to CRAN and then maintain it
@m0nhawk They do to some extent. I've gotten specific comments on submission.
@Frank Heh, Backward compatibility is the second topic there
20:45
:)
I mean they didn't check package on each submission (new versions).
yeah, they might just use automated checks
There is about a million checks.
How the F is this getting upvotes??!?! Please close and delete.
3 up-votes???? How?
He must have a voting ring
yeah, looks spammy
20:54
4 upboats
let's quickly dump downvotes on it so we can delete, eh
9 views, 4 upvotes
Yeah that's spam
@BhargavRao - Can you have a look?
@Axeman I actually thought it was a funny one :)
@DavidArenburg It was getting annoying ;)
last del vote on that ^
@RichScriven something certainly fishy. It needs some work, I've bookmarked it, I'll take a look as soon as I get up tomorrow morning.
The older one just got an upvote when I brought it to the room's attention. Someone in here is upvoting too. Nice.
@Frank hmm, I don't see a delete option
is this some yet another ancient SO rule of a question with 3 upvotes can not be delete or something?
oh, it got a 5th upvote
savage
yeah, we need it at -3 or something to delete this soon
i custom flagged it, we'll see how that goes
Otherwise we have to wait till "on-hold" changes to "closed"
Bohemian closed another of the user's questions, so i guess is aware of this gobbledygook posting pattern
ok, deleted that one
huh, didn't think digg was still a thing:
Please avoid making short, undocumented answers. Please do NOT digg questions many years old, specially those commented with related links to already accepted answers. Good luck. — Ruslan Abuzant 18 hours ago
anyway, the answerer's example very much does not work
edit(mean) does, though, albeit not read-only, i guess
@BhargavRao Thanks.
@Frank That really looks like a bug btw
If this works tb[,.(x=sum(x)), by=.(y, zz=get("z"))], why not this tb[w != "a",.(x=sum(x)), by=.(y, zz=get("z"))] ?
We can delete this one too.
21:14
@RichScriven not sure about that one
the question was closed as unclear, not as a tool. But it seem to get a good and useful answer
mm, okay. Fair enough
a tool question could be always deleted IMO cause it isn't supposed to be answered, but an unclear question that become clear and helpful- probably not
though it probably needs some editing
I voted, so it's going to go to the delete queue anyway
We'll let the others decide ;)
One more dv for delete on the original
21:18
We need to bring back that gif from the trash :)
ok, its gone
Wow, OP deleted it.
That was quite a challenge!
nothing is a challenge for this room :)
Nope, that user is toast.
Account gone
wow, that was fast
@BhargavRao, you assassinated him?
Must have been an obvious ring to the mods
Another satisfying day of moderation.
21:25
I see people keep saying on Meta that after 10K rep you pretty much have no more moderation privileges to earn, while they keep forgetting that 3 20K can delete a question/answer within seconds- I would like to see that been done by 10K users
not to mention that you literally can't have an hummer with 10K rep
@Frank It works in RStudio, which overloads View.
here we go...
lol
I had to.
I know :)
this must have a thousand dupes stackoverflow.com/questions/41600594/…
user image
3
Spot on
21:34
@DavidArenburg the sequence things are evaluated in is subset by i, then group by by, then evaluate j. i guess by= expects to get vectors that are the full length of DT rather than the subset DT[i]..?
so we keep politics low key here, just gonna star messages that i approve of
I know. It was too good not to share though
@Frank That maybe, but is it intended ?
I think we can discuss politics here freely
we are all grown-ups
@Axeman ok, thanks. you could edit that in if you think the answer's worth keeping around
@Frank I made a comment to that extent.
21:36
@DavidArenburg dunno, i've bumped up against it a couple times, i think, though not using get()
@Axeman ok
@DavidArenburg ok, fine by me. i just saw no one was really doing it so figured it was an implicit rule / etiquette
@Frank I yhought doing eval/as.name combo and it indeed works in some cases
arg <- "z" ; tb[w != "a", .(x=sum(x)), by = .(zz = eval(as.name(arg)))]
but no in this case
tb[w != "a", .(x=sum(x)), by = .(y = y + 1, zz = eval(as.name(arg)))]
which makes me wonder because the error looks very similar
@Frank My wife doesn't like politics, so who am I supposed to discuss those with?
@DavidArenburg heh, fair enough
@DavidArenburg bye = substitute(quote(.(y = y + 1, zz = arg)), list(arg=as.name(arg))); tb[w != "a", .(x=sum(x)), by = eval(eval(bye))]
not sure why the double eval is needed, i kind of hate working with this stuff
21:57
@RichScriven @Frank It was a network of sock puppets created by a central user to evade multiple question bans. This has been handled, but they appear to be trying to create new accounts, so we'll keep an eye on this. Thanks for pointing it out
ok, thanks Brad
Thanks @BradLarson

« first day (630 days earlier)      last day (2893 days later) »