Is it possible to merge adiacent cells in a wx.grid? I mean both horizontal as cells in a row and vertical as cells in a column.
There is a way to make text span multiple rows or columns in a grid widget. There's an example in the wxPython demo called GridSimple.py. See lines 64-67. They read as follows:
self.SetCellValue( 9, 1, "This default cell will overflow into neighboring cells, but not if you turn overflow off.");
self.SetCellSize(11, 1, 3, 3);
self.SetCellAlignment(11, 1, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE);
self.SetCellValue(11, 1, "This cell is set to span 3 rows and 3 columns");
Note: You don't need the semi-colons. I don't know why they're in the example.
Related
For the sake of simplicity, I will refer to column as col.
Why are matrices defined as [rows, columns] and not [columns, rows]?
It has just caused me a ton of headaches and confusions.
My thinking goes this way:
A regular array:
[1, 3, 5, 2, 4]
is like a matrix with one row and multiple cols. And it is notated like that: arr[n].
And so if we had another dimension:
[1, 3, 5, 2, 4]
[1, 3, 6, 3, 6]
there are now rows. So let us notate the rows after the 'n', arr[n, rows], but the reality shows us otherwise.
In addition, a matrix of 2 dimensions can be looked at as a cartesian coordinate system (where the direction of the y axis is flipped, the origin is element [0,0]). in the plane, we notate points like that: (X,Y).
It looks like the cols are sitting on the x axis and the rows are on the y axis, so why not notate the elements of matrices like that: [Cols, Rows]?
Sorry if I've confused you, and sorry for my ignorance.
IMO, this is bound to latin typographical conventions.
Latin writes from left to right, then top to bottom.
Following these conventions, a Matrix is decomposed into nRow rows.
Each row is then decomposed into nColum elements, much like you would decompose a text in sentences, and sentences in words.
Information is thus organized with a most significant arrangement (rows) and least significant (column).
Following same convention as latin (err arabic) number notation, we have most significant nRow on the left (first if you are latin), and least significant nColumn on the right, thus (nRow,nColumn) for describing the layout.
Naturally, accessing a single element at row iRow and column jCol follows same convention (iRow,jCol).
Note that information can be arranged completely differently in underlying software. For example, for multi-dimensional arrays in FORTRAN and Matlab, first indice vary first, and the sequence in memory is x(1,1) x(2,1) x(3,1) ... x(1,2) x(2,2) x(3,2) ... sort of column-wise order if we consider that left (first) is row index, right (last) is column index. Or maybe some optimized library will have arranged a block layout for the matrix.
So Im creating this grid-chart and I really want to have the following values in my X-Axis:
"<10"
"<20"
">20"
I want my graph to look something like the following graph, in the link below:
Graph example
The nodes X values does not have the lesser than (<) or bigger than(>) symbols, they are just numbers spanning from 1-30 with no extra characters. Chosing only that field as the x-axis doesnt do it, ofc. I only want those three specified values, containing the symbols (< and >), in the X-axis.
I feel like this should be a simple thing to solve, but I've tried for a while now without any succes...
Sorry about the poor example, hopefully you understand what i'm saying
Any ideas?
Thanks in advance.
Have a look at the Class function.
The class function assigns the first parameter to a class interval. The result is a dual value with a<=x
You could create a grid chart and use PplWatched and Rating as dimensions with expression count(id) using the following testdata:
Data:
load
id, class(PplWatched, 10) as PplWatched, Rating
;
load * inline [
id, PplWatched, Rating
1, 14, 4
2, 2, 2
3, 19, 5
4, 30, 4
5, 9, 1
6, 45, 5
];
This is a simple problem, however I cannot find an elegant solution for:
Given is the following vector series:
series=c(1,2,4,5,6,1,2,4,5,6,7,8,2,4)
I now want to count blocks of this vector in the same vector; e.g. if I have a block size of 2, I would like to count the pairs 1&2, 2&4, 4&5 and so on (in total 8 unique blocks if I did the counting right).
Can you think of an easy way to program that so that I receive an output matrix with a column for the "unique block number" and a corresponding column for the counts?
One idea is to can use rollapply from zoo,
nrow(unique(rollapply(series, 2, by = 1, paste0)))
#[1] 8
You can change '2' to get combinations(block sizes) of 3, 4, etc...
I need to delete one particular matrix from the matrix space in sage.
For example matrix space is MS = MatrixSpace(GF(2), 1, 2). I want to delete MS[0] from MS in sage.
I'm doing some work with arithmetic sequences modulo P, in which the sequences become periodic under the modulo. My worksheet generates a sequence mod P with the first term being 0, the second term being a number K (referencing another cell), and the following terms following the recurrence relation. The period of the sequence (number of values before it repeats itself) is related to the ratio P/K, s, for example, if P=2 and K=1, I get the sequence {0,1,1,0,1,1,0,1,1,...}, which has a period of 3, so when P/K=2, the period is 3.
I currently have a formula which uses the COUNTIF function to count the number of zeroes in the range, which is then divided out of the total range, currently an arbitrary size of 120, and this gives me the correct period for many ratios of P/K. Most of the time, however, the sequence generated exhibits semi-periodicity and sometimes even quasi-periodicity, such as in the case of K=1 and modulo 9: {0,1,1,2,3,5,8,4,3,7,1,8,0,8,8,7,6,4,1,5,6,2,8,1,...}, where P/K=9, the period is 24, and the semi-period is 12 (because of the 0,8,8,... part of the sequence). In such cases, my current COUNTIF formula thinks the full period is 12, even though it should be 24, because it counts the zeroes which define the semi-period.
What I would like to do is adjust the formula so that instead of the criterion for counting being 0, it would only count triplet sequences of cells in the pattern 0,K,K.
My current formula:
=QUOTIENT(120,(COUNTIF(B2:DQ2,0)))
So if I have =QUOTIENT(120,(COUNTIF(B2:DQ2,*X*))) I want the "X", which is currently 0, to reference a specific sequence of cells, namely the first three of the overall series, so something like: =QUOTIENT(120,(COUNTIF(B2:DQ2,(0,C2,D2)))) although obviously that criterion is not in remotely the correct syntax.
I'm not well-versed in writing macros, so that would probably be out of the question.
I would do this with four helper rows plus the final formula. Someone more clever than I am might be able to do it in one cell with an array formula; but compared to array formulas I think the helper rows are easier to understand and, if desired, tweak.
Once this is set up, if you're always going to use three as your criterion, you can hide the helper rows (to hide a row, right-click on the gray number label on the left side of the spreadsheet, and choose "hide").
So your sequence is in row 2, starting in column B. We'll set up the first helper row in row 3, starting in column C. In cell C3 put the formula =C2=$B$2. This will evaluate to FALSE, which is equivalent to 0. Copy and paste that formula all the way to cell DQ3 (or however many columns you want to run it). Cells below a sequence number equal to the first number in the sequence will evaluate to TRUE, which is equivalent to 1.
The next two helper rows are very similar. In cell D4 put the formula =D2=$C$2 and copy and paste to cell DQ4. This row tests which cells are equal to the second number in the sequence.
In cell E5 put the formula =E2=$D$2 and copy and paste to cell DQ5, showing which cells are equal to the third number in the sequence.
The last helper row is a little different, so I left an empty row after the first three helpers. In cell E7 I put the formula =SUM(C3,D4,E5); copy and paste that over to column DQ. This counts how many matches were found in the previous three helper rows. If all three match, the result of this formula will be 3 and your criterion for determining the period will have been fulfilled.
Now to show the period: in the cell you want to have this number, put the formula =MATCH(3,E7:DQ7,0). This searches the last (fourth) helper row looking for a cell that is equal to 3. (Obviously you could modify this method to match only the first two sequence numbers, or to match more than 3, and then you'd adjust the first parameter in the MATCH formula.) The last parameter in this MATCH formula is 0 because the helper row is not sorted. The return value is the index of the first match: a match in E7 would be index 1, a match in E8 would be index 2, etc.
I tested this in LibreOffice 4.4.4.3.