I want to create a new sprite for my page, and I'm wondering that whether we can create a sprite of 25 images in 5 rows and 5 columns.
Yes, you can generate a sprite sheet in any number of rows and columns you like. You access the particular sprite you want with CSS positioning, so it doesn't matter how many rows and columns you have, as long as you know the coordinates of each, this isn't an issue.
Related
I’m trying to emulate Minesweeper in Google Sheets, and for this I want to create a second map adjacent to the first with all of the correct values already in it. To randomize bomb position, I need a list of random numbers or cells(cells would be preferable). However, I cannot figure out how to do this without ending up repeating numbers. The result would ideally be a vertical array of cell coordinates. Thank you!
Answer
The following formula should produce the result you desire:
=SORTN(FLATTEN(MAKEARRAY(10,10,LAMBDA(row,col,ADDRESS(row,col)))),20,,RANDARRAY(100),)
In =MAKEARRAY, change the first 10 to adjust how many rows to randomly choose from, or the second 10 to adjust how many columns to choose from. The value in =RANDARRAY must be equal to the product of the number of rows and the number of columns. (e.g. in the above example, 10*10=100).
Change the 20 to adjust how many randomly chosen values to return.
Explanation
=MAKEARRAY is used to generate an array of every possible row and column combination. It accepts a =LAMBDA, which in this case is just the =ADDRESS function. The first two arguments of =MAKEARRAY determine how large the array should be, which is why changing them adjusts how many rows/columns to randomly pick from.
Then, the result of =MAKEARRAY is squashed into a single column using the =FLATTEN formula.
Finally, the entire thing is sorted randomly using =SORTN combined with =RANDARRAY. =SORTN also limits the number of results that are returned dependent on its second argument, which is why changing it adjusts how many results are returned.
If you want information on how to "freeze" the value of =RANDARRAY so it doesn't recalculate each time you change something, check out this question by player0.
Functions used:
=MAKEARRAY
=LAMBDA
=ADDRESS
=FLATTEN
=SORTN
=RANDARRAY
I am trying to replicate the plot below (done with ggplot in R) using Tableau:
However, I can't see how I can subset the plot so it fits the screen using Tableau. Using Tableau, this is what I get:
I've attempted adding the following but it stops plotting the histograms and ends up messier:
Row Divider (Discrete):
INT((INDEX()-1)/(ROUND(SQRT(SIZE()))))
Columns Divider (Discrete):
(INDEX()-1)%(ROUND(SQRT(SIZE())))
How can I achieve the plot in R using Tableau?
P.S.: The datasets are different in case you were wondering why Monday doesn't look the same.
You're on the right path using Row-Column divider, but you need to go some step further using the small multiple technique.
For instance, you need to move WEEKDAY in the detail mark and then, use column and row divider in column and row shelf.
Doing so, you'll also need to right-click on CNT/Ride Id Hash) and compute it with WEEKDAY.
Here's a cool guide by a Tableau Zen master showing how to work with this tecnique: https://www.vizwiz.com/2016/03/tableau-tip-tuesday-how-to-create-small.html
I tried to plot arrival delay and departure delay columns separately, it's clear the distributions are different.
I would like to show them on the same plot, but whenever I try to do so, both plots became one identical shaped distribution although I'm plotting two different columns! What am I doing wrong?
Thank you for your help in advance.
You need a Departure Delay (bin) field. You can create one by selecting Departure Delay in the data pane on the left sidebar and selecting Create bin.
Once you have that new field, you can place it on the Columns shelf next to the other bin field and just put SUM([Number of Records]) on the Rows shelf — getting rid of both CNT() fields.
That should let you see both histograms.
To answer your question about why your previous approach yielded the same chart, you were binning data in both cases by the Arrival delay.
The CNT([xxx]) fields are misleading. That just counts the number of records that have a non-null value in the [xxx] field. If [xxx] always has a value, its equivalent to SUM[Number of Records]). The bin field is what matters.
I'm coaching a little league team and would like to keep track of how many times a player has played a certain position in a game. I have a table with the available positions as column headers and enter the name of the player who played at that position after each game.
Here is an image of the table:
I'd like to output a chart or table where I can easily see how many times the players have played in the various positions.
How would I do this most efficiently?
Add a column on the left below your existing table, list all players names there (one row each) then use a COUNTIF formula (under Pos A and copied across and down), eg:
=countif(B$2:B$3,$A5)
I want to generate the number 2 5 times and the number 1 10 times. I'm trying to spread these across a String Grid in Delphi randomly. I also want to fill the rest of the grid that isn't 1 or 2, with 0's. I have no idea how to even start here.
It would look something like this (P stands for player and there would only be 5 2's and 10 1's): https://gyazo.com/aeef05c3a92ce7847c0f42ad40faa733
Given a grid with dimensions m×n, create an array of length m * n. Put five 2's and 10 1's in the array, and fill the remainder with 0's. (We'll assume the product of m and n is at least 15.) Shuffle the array. Copy each element of the shuffled array into successive cells in the grid.
While the approach represented in Robs answer will do the job I personally think it is way to complicated for it's purpose.
So what would be more simpler approach?
Well your goal is to place these numbers at random positions in grid.
How do you determine position of some object in a grid? You do it by its X (Column) and Y (Row) coordinates.
So how do you get random position in a grid? Simple chose two random values for X and Y coordinates.
As for placing certain numbers of number 1 and number 2 use two simple loops.