Just the ranks

  • Comments posted to this topic are about the item Just the ranks

  • That is really interesting , thanks Steve
    Learned something new today...

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

  • Now that was unexpected! Learned something new, thanks Steve.

    ...

  • Would never guess. It seams to be illogical for me. 🙂

  • nice question, thanks

    ---------------------------------------------------------------------------------------
    The more you know, the more you know that you dont know

  • I think the answer or in fact, the explanation is incorrect and/or incomplete.
    My assumption is that the the numbers between the brackets are first "calculated", and then the following logic is applied:

    • If the 0 > "calculated" <= number of columns: return column["calculated"].
    • If the -(number of columns) >= "calculated" < 0: return all columns, but exclude "calculated".
    • if "calculated" = 0:  return nothing.
    • if "calculated" > number of columns:  error undefined column.
    • if "calculated" < -(number of columns): return all columns.
    So:

    • HR.hitter[1-3] = HR.hitter[-2] => return all columns except for column 2.
    • HR.hitter[1-2-3] = HR.hitter[-4] => return all columns. 

  • I don't quite know how this works. It was surprising to me as well. i suspect this is some strange holdever from the past, perhaps some poorly designed behavior in the language. I could do  HR[.1:3], or I've seen HR[,c(1,3)] as well.

    Can't test this now, but I think there are lots of ways. I thought this was interesting, because I would assume 1-3 is the range.

Viewing 7 posts - 1 through 6 (of 6 total)

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