« first day (560 days earlier)      last day (2745 days later) » 

12:01 AM
Please close and then possibly delete this post: stackoverflow.com/q/40370118/4891738
It completely makes no sense. He / She got the algorithm wrong.
h is the surface which we aim to search the minimum; then we should first find the first derivative of h, then use it for the direction of step. However, the question simply takes h itself as the direction.
The accepted answer is misleading in anyway. Upon correct implementation, no NaN is expected.
 
@alistaire would changing from stop = lead(start) - 1 to stop = start + length - 1 make any big problems for your answer? I ask because I was trying your answer with r <- rle(c(0,0,0,0,0,1,0,0,0,0,0,0) == 0)
 
12:20 AM
@Jota That looks like it should work fine. stop is a lot easier to calculate than start, which I managed to screw up a few times before I got it right.
 
@alistaire your way of calculating start is pretty clever. My first thought with adjusting stop was to mimic start and make use of default (lead(start, default = sum(length) + 1) - 1)), but it's not as clear.
 
Thanks! I'm actually taking a second look; I think it may actually be simpler to calculate stop first.
Oh definitely: mutate(stop = cumsum(length), start = stop - length + 1)
 
oh yea, that's nicer
 
2:02 AM
@Frank I flagged a couple as "not constructive", which usually gets them deleted quickly. It doesn't help for anything complicated, though.
 
 
1 hour later…
3:20 AM
@Jota nope, i see the full avatar
@alistaire ok, maybe i should use them more. i don't really mind comment clutter, though, really
 
 
4 hours later…
8:08 AM
Hello
 
8:19 AM
hi @Tensibai
 
9:03 AM
Should I report this to Arun and Matt? set really shouldn't be slower than [<-.data.frame.
3
A: What is the fastest way to update a data set in R?

hannes101Interestingly enough, if you're using a data.table it doesn't seem to be faster at first glance. Perhaps it's getting faster when using the assignment inside of a loop. library(data.table) library(microbenchmark) dt <- data.table(test) # Accessing the entry dt[765, "C", with = FALSE] # Replac...

 
9:25 AM
@Roland I would think so
 
Can someone test with the development version? I can't install it right now.
 
[<-.data.frame still makes a copy (at least on 3.3.1)
set.seed(1234)
test <- data.frame(A = rep(LETTERS  , 800), B = rep(1:26, 800),    C=runif(20800), D=runif(20800) , E =rnorm(20800))
tracemem(test)
# [1] "<0x496da40>"
test[765, "C"] <- test[765, "C"] + 25
#tracemem[0x496da40 -> 0x48fc660]:
#tracemem[0x48fc660 -> 0x48e2d48]: [<-.data.frame [<-
#tracemem[0x48e2d48 -> 0x48e2e18]: [<-.data.frame [<-
 
9:54 AM
@Roland Seems set takes advantage over 15k rows
Single row:
Unit: microseconds
 expr     min      lq     mean  median      uq     max neval cld
    a 238.616 244.322 255.6668 253.870 266.842 273.972    10  b
    b 332.982 340.394 415.8558 345.382 477.520 797.672    10   c
    c  73.836  82.390  94.0220  92.797  99.782 130.854    10 a
20k rows: (test data reinitialized inbetween):
Unit: microseconds
 expr     min      lq     mean  median      uq      max neval cld
    d 421.644 434.472 684.8916 486.073 624.622 2307.770    10   a
    e 494.910 519.144 588.2192 564.329 579.866  837.014    10   a
    f 531.688 559.624 771.3294 573.877 603.814 2473.692    10   a
Just changed the i from single value to 1:20000
 
@Tensibai Okay, but it shouldn't be slower when you assign a single row. As David shows [<-.data.frame makes a copy of the whole data.frame whereas set should not do that and thus should be faster.
 
10:18 AM
I didn't had a look at set code for now
Looking at the code, as the values are updated by reference set checks the input are valid indexes before doing anything, may explain the overhead
(and I'm happy they do it)
From line 444-446:
 // having now checked the inputs, from this point there should be no errors so we can now proceed to
    // modify DT by reference.
 
11:30 AM
Tool.
0
Q: changepoint.meanvar() equivalent in python

Mahesha999I am planning to do some changepoint analysis in python. I know there is an elaborate package in R: changepoint. However I am unable to find any equivalent package in python. Is there any good package available in python for similar purpose and equally matured? Specifically I am interested in e...

 
12:23 PM
-1
Q: Aggregate column but split according to column's values in R

WboyA very quick question, I'm more familiar with a python / pandas background,and I'm wondering how to do this in R. Google isn't helping me with this. I have a dataframe of Date Venue Assuming Venue has 5 distinct values, I want to aggregate this to get the following form: The count of each dis...

@ProcrastinatusMaximus Doesn't seem to be right duplicate..
Long to wide maybe?
 
Added a comment with a link to such an example :-)
 
okays..cool.
 
 
3 hours later…
3:06 PM
Is it possible to heatmap labels in ggplot?
I'm imagining the labels being greener as the values get to the top right, and redder as they get to the bottom left
 
add a fill aesthetic
e.g. ggplot(data.frame(x = 1:10), aes(x, x, label = x, fill = x)) + geom_label() + scale_fill_gradient(low = 'red', high = 'green')
 
nice that worked.
much appreciated @alistaire
 
np!
 
3:26 PM
Close this one as typo: stackoverflow.com/q/40382195/4891738 Wrong specification of function arguments.
Well, it might not be an obvious typo as documentation for that tiny package is poor. But, it is still a typo
Is an answer of this format acceptable: stackoverflow.com/a/7964954/4891738?
 
3:42 PM
@ZheyuanLi back then it was acceptable I guess, nowadays a lot less
 
I have not been on this site for long; so not sure what situation was years ago.
Maybe in earlier time when there were not many R questions, pretty much everything will be voted up...
 
imo: just let it be
 
I know; there is also nothing we can do I guess.
 
This plot by @Gregor is sick stackoverflow.com/a/13334294/4564247
It'd be cool to do that in ggplot
 
looks doable
 
3:49 PM
Wouldn't the counts be messed up on the x scale?
 
you could cheat with facets
or use densities to constain them to a common scale (there is no scale for the counts anyway)
 
That's true. And you could prob add the density curve in the meantime
 
@Axeman maybe better to use geom_segment?
 
geom_rect no?
but that would be require some more prep. Would be the most flexible solution in the end though
@PierreLafortune Are you actually interested in a proper ggplot solution there?
 
4:01 PM
I am. I have a report I'm working on
 
similar to that plot in the answer, or do you want to draw other stuff, like the plot in OP
 
No just the answer.
I have five hists
             name overall_att overall_attdemo best_att best_attdemo usage
2      Shopping22      10.538           3.658   30.762       14.544 0.056
3         Views46       9.255           3.542   24.479        7.105 0.073
4 Lifestyle_Net17       7.938           3.512   11.819        8.855 0.056
5      Shop_Beh10       7.127           3.304   16.175       10.387 0.053
6          Diet16       7.633           3.254   20.616       14.498 0.057
7       Privacy17       9.343           3.208   30.306       13.055 0.018
Instead of five plots. I'll try to get them onto one chart
 
with facets:
ggplot(diamonds, aes(price)) +
geom_histogram() +
coord_flip() +
facet_grid(~cut) +
theme(panel.spacing = grid::unit(0, 'lines'))
 
I have ggplot2_2.1.0.9000. It doesn't seem to recognize "panel.spacing"
Are you using devel?
 
Yup, might be panel.margin instead
All facetting is being changed right now by the intern
 
4:12 PM
@PierreLafortune I'd just use geom_violin and be done with it:
ggplot(data, aes(x = bin, y = ReleaseDOY)) +
  geom_violin(scale = "count", draw_quantiles = c(0.25, 0.5, 0.75))
 
@Roland I agree.
ggplot(diamonds, aes(price)) +
  geom_histogram(aes(y = ..density..), col = 'black', fill = 'white') +
  coord_flip() +
  facet_grid(~cut, switch = 'x') +
  theme(panel.spacing = grid::unit(0, 'lines'),
        strip.background = element_blank(),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank())
 
It looks good, but I need to figure out the scaling. My data is a bit disparate
It's the same with the violins
 
for the violins you can change the scale argument
for the histogram with facets you can always just use scales = 'free_x', though I think you need the dev version
 
4:29 PM
@Axeman got it going. thanks a lot for that
Just going to clean it up
 
You transformed value then?
 
I scaled beforehand
 
 
1 hour later…
6:11 PM
 
 
5 hours later…

« first day (560 days earlier)      last day (2745 days later) »