I'm drawing a HUGE blank here.
Everything I've found is about getting an index from a given row and column, but how do I get a row and a column from an index?
The row is easy: (int)(index / width)
.
My brain is suffering massive bleed trying to compute the column.
Shame on me.
The dataframe column can be referenced using the $ symbol, which finds its usage as data-frame$col-name. The which() method is then used to retrieve the row number corresponding to the true condition of the specified expression in the dataframe. The column values are matched and then the row number is returned.
Just click the column header. The status bar, in the lower-right corner of your Excel window, will tell you the row count. Do the same thing to count columns, but this time click the row selector at the left end of the row. If you select an entire row or column, Excel counts just the cells that contain data.
For a zero-based index, the two operations are, where width
is the width of the structure:
row = index / width column = index % width
Those are for C using integers, where the division rounds down and the %
modulo operator gives the remainder. If you're not using C, you may have to translate to the equivalent operations.
If you don't have a modulo operator, you can use:
row = index / width column = index - (row * width)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With