CUTting data

  • Comments posted to this topic are about the item CUTting data

  • That is a really strange way to cut data.
    Interesting question, thanks Steve.

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Stewart "Arturius" Campbell - Wednesday, May 16, 2018 12:05 AM

    That is a really strange way to cut data.
    Interesting question, thanks Steve.

    Strange is a lot gentler than I was coming up with. I have read and reread that link and it makes no sense to me what is going on there. The output to me make absolutely no sense I don't get the meaning of Steve's comment..."pad the spaces a bit to ensure all values fall into the buckets it has created.".

    Can somebody explain in a way that makes sense?

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Sean Lange - Wednesday, May 16, 2018 7:18 AM

    Stewart "Arturius" Campbell - Wednesday, May 16, 2018 12:05 AM

    That is a really strange way to cut data.
    Interesting question, thanks Steve.

    Strange is a lot gentler than I was coming up with. I have read and reread that link and it makes no sense to me what is going on there. The output to me make absolutely no sense I don't get the meaning of Steve's comment..."pad the spaces a bit to ensure all values fall into the buckets it has created.".

    Can somebody explain in a way that makes sense?

    I guess only Steve can meaningfully explain what he meant by that.

  • Revenant - Wednesday, May 16, 2018 2:26 PM

    Sean Lange - Wednesday, May 16, 2018 7:18 AM

    Stewart "Arturius" Campbell - Wednesday, May 16, 2018 12:05 AM

    That is a really strange way to cut data.
    Interesting question, thanks Steve.

    Strange is a lot gentler than I was coming up with. I have read and reread that link and it makes no sense to me what is going on there. The output to me make absolutely no sense I don't get the meaning of Steve's comment..."pad the spaces a bit to ensure all values fall into the buckets it has created.".

    Can somebody explain in a way that makes sense?

    I guess only Steve can meaningfully explain what he meant by that.

    Honestly it isn't just his explanation that has left me scratching my head. The link from the answer doesn't clear it up for me either. I don't get it.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Sean Lange - Wednesday, May 16, 2018 2:36 PM

    Revenant - Wednesday, May 16, 2018 2:26 PM

    Sean Lange - Wednesday, May 16, 2018 7:18 AM

    Stewart "Arturius" Campbell - Wednesday, May 16, 2018 12:05 AM

    That is a really strange way to cut data.
    Interesting question, thanks Steve.

    Strange is a lot gentler than I was coming up with. I have read and reread that link and it makes no sense to me what is going on there. The output to me make absolutely no sense I don't get the meaning of Steve's comment..."pad the spaces a bit to ensure all values fall into the buckets it has created.".

    Can somebody explain in a way that makes sense?

    I guess only Steve can meaningfully explain what he meant by that.

    Honestly it isn't just his explanation that has left me scratching my head. The link from the answer doesn't clear it up for me either. I don't get it.

    Apparently this is a tricky one. 14 hours after posting and we have only 170 attempts with only 22 percent correct.

  • Well, I guess I better start learning R.  I just took a logical guess and was wrong.  The correct answer makes no sense to me at this time.

  • Lynn Pettis - Wednesday, May 16, 2018 3:30 PM

    Well, I guess I better start learning R.  I just took a logical guess and was wrong.  The correct answer makes no sense to me at this time.

    And here i thought i was losing my marbles. i'm glad i'm not the only one totally confused by the linked page.

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Ah, well - R is even nerdier than you think!

  • Sorry, pad the space in each interval to get values inside of the spaces. I don't quite understand the exact math used here myself, and I've struggled to determine the algorithm.

    I was hoping one of you R people would give me a better explanation. I would have assumed 0-5, 5.000001-10, etc.

  • Steve Jones - SSC Editor - Thursday, May 17, 2018 4:00 AM

    Sorry, pad the space in each interval to get values inside of the spaces. I don't quite understand the exact math used here myself, and I've struggled to determine the algorithm.

    I was hoping one of you R people would give me a better explanation. I would have assumed 0-5, 5.000001-10, etc.

    That is what I would think would make sense. Not really sure how cutting the data into segments results in values outside the original values. And the values it produces remind me of some of the forum posts we see.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • An interesting question, thanks Steve. Explaining the cut function is not easy for short. In one or two sentences impossible.
    First I found the syntax of the cut function in RDocumentation and a simple example in Learning the 'cut' function - RPubs.
    Then I was a bit brighter and I was able to use the function cut according to the QotD, split the vector into 4 intervals, see the R code v3.4.1 below.
    Those of us who can not run the code and verify their result right in R they have it tough.
    Execute
    #QotD 20180516
    x = c(1:20)
    print(x)
    cut(x, breaks=4, labels=c("1-5", "6-10", "11-15", "16-20"))

    Result
    $Rscript main.r
    [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    [1] 1-5 1-5 1-5 1-5 1-5 6-10 6-10 6-10 6-10 6-10 11-15 11-15
    [13] 11-15 11-15 11-15 16-20 16-20 16-20 16-20 16-20
    Levels: 1-5 6-10 11-15 16-20

  • I guessed correctly based on the definition being 'cut divides the interval into equal segments and then moves the outer limit by 0.01%' a bit bizarre IMHO but there you go, the only figure that seemed to fit was 0.981 which IS the 0.01% of the difference of 19 (from 1 to 20). The rest of the figures may have some obscure "level" dependency but have not worked out how.

    ...

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply