I want to drawing a graph with a huge number of nodes/connected components, but unfortunately Graphviz lays all of connected components side-by-side, and since my connected components consists of only a few nodes, the image looks like this:
n1 n3 n6 n7 n8 n9 n10 n11 n12 ... n999
| | \ | |
n2 n4 n5 n13 n13
|
n14 # all trees have very little heights
so I end up with an image with resolution 500000 x 100 which is really messy to work with.
I'm using default settings for digraph, and my .dot file looks like this:
digraph {
n1 [ style=dashed; color=grey ]; # I just override node style and color
...
n1 -> n2;
...
}
and I use the following to generate an image: dot -Tpng > mygraph.dot
Is it possible to somehow make the layout automatic but specify:
max width only, e.g. 8.5 inches, so I can easily break up into letter-size paper pages and print it
any size but make width as close to the height (e.g. I want an image of square shape)
?
Edit:
E.g. for the case above, I would be hoping for something like:
n1 n6 n8 n10
| |
n2 n7 n13 n11
| |
n3 n14 n13
| \
n4 n5 n9 n12
...
n999
Related
I'm rather new to excel and I want to use excel or perhaps another program to subtract on a fixed amount but randomly.
It is like n1 + n2 + n3 = 300
But I want n1 and n2 and n3 to be different numbers hence not division
Examples
150 + 75 + 75 = 300
or
100 + 100 + 100 = 300
or
50 + 100 + 150 = 300
A function to subtract a fixed amount but random subtraction
I'm still quite confused on how to do this on excel, sorry for my bad English and explaination
Please help.
If it is always 3 numbers:
The first number we use:
=RANDBETWEEN(1,A1)
Then the second:
=RANDBETWEEN(1,A1-B1)
Then the third is just the remainder:
=A1-B1-C1
In excel you have your numbers in rows and columns
I would enter 100, 100 , 100 in separate columns of the same row and then use this
formula
=(A1+B1+C1).
Meaning row A1 100, row B1 100, row C1 100. The answer should be 300
if you want to subtract just use the minus sign instead of the plus sign:
formula =(A1-B1-C1).
Try:
=LET(A,RANDBETWEEN(0,300),B,RANDBETWEEN(0,300-A),HSTACK(A,B,300-SUM(A,B)))
Or, if no HSTACK() available:
=LET(A,RANDBETWEEN(0,300),B,RANDBETWEEN(0,300-A),CHOOSE({1,2,3},A,B,300-SUM(A,B)))
I'm just unsure if pure mathematically this is as random as can be. Would it be 'more random' if one would list all possible permutation of 1-300 that would add up to 300 and randomly pick a solution from this list?
One way to approach this if you want two numbers to always add up to the same value, is to modify each value with the same amount, by adding to one value and subtracting from the other
100 = n1 + n2 = (n1+a) + (n1-a)
where a is any random number.
To extend this to three numbers, you can use two artbitrary numbers a and b to do this following
100 = n1 + n2 + n3 = (n1+a) + (n2-a+b) + (n3-b)
The simplified approach to this it to pick completely random n2 and n3 and let n1 pick up the difference
100 = (100-n2-n3) + n2 + n3
To do this in Excel, use the =RANDBETWEEN() function for n2 and n3 and then for n1 just subtract from 100
=100 - SUM(n2,n3)
I have excel worksheet with :
three columns A, B, C with coloured animals:
cell D1 with dropdownlist with values: cat, dog, elephant, rabbit, lion
cell E1 with dropdownlist with values: yellow, red, white
Example data are like below:
A B C
---------------------------------------------------------
1 | cat yellow my loved yellow cat
1 | cat yellow my hated yellow cat
2 | cat red my favourite red cat
3 | dog white ugly white dog
4 | dog white elegant white dog
5 | elephant white beauty white elephant
6 | elephant yellow tiny yellow elephant
7 | rabbit red small red rabbit
8 | lion red red lion for my son
9 | lion white my pet lion white
Now in cell F1 I need to have the dropdown list dependent on values selected in cells in D1 and E1. So If you will select in D1 cat and in E1 yellow, you should have in F1 two options to select:
my loved yellow cat
my hated yellow cat
The solutions with one dependent column I do it:
Data -> Validation -> List -> in formula I paste:
=OFFSET($C$1,MATCH(D1,$A$1:$A$9,0)-1,0,COUNTIF($A$1:$A$9,D1),1)
But this filter only by animals and I have in dropdown three cats: my loved yellow cat, my hated yellow cat, my favourite red cat. But I need only yellow cats! Is method to create it like desctibed below?
Have a look here, there something very similar.
I think this is what you are looking for:
=IFERROR(INDEX(C1:C10, SMALL(IF(1=((--(D1=A1:A10))*(--(E1=B1:B10))), ROW(C1:C10),""), ROW())),"")
I have an If formula in Excel as seen below:
=IF((Q2="O")*AND(R2="O")*AND(S2="O")*AND(T2="O")*AND(U2="O"),"O","X")
Basically, if cells Q2 to U2 is O the cell with formula will have O written in it. Otherwise it will have X. Now I want to change it into a nested If statement due to new conditions.
These conditions, in order are:
If any one of cells Q2 to U2 = X, cell = X
If any one of cells Q2 to U2 = date format, cell = ∆
If Q2 to U2 = O, cell = O
If none of the conditions are met, the cell will have value "FALSE". (Default appears)
Each of the cells have this condition to follow,
If any one of cells Q2 to U2 = -, ignore that cell and count the other cells to get final result.
I tried switching to Or in my original formula to test out conditions 1 and 3.
=IF((Q2="O")*or(R2="O")*or(S2="O")*or(T2="O")*or(U2="O"),"O","X")
But it doesn't work. Plus I'm not sure how to do condition 5 as well. Any help?
Is it possible to do something so complex just by using Excel formula? Or do I need to go into VBA?
Things like this are usually easier if you tackle the problem in order of priority. It looks like 1 has the highest priority:
=IF(COUNTIF(Q2:U2,"X")>0,"X","Does not contain X")
COUNTIF(Q2:U2,"X") returns the number of occurrences of X in the range Q2:U2.
In place of "Does not contain X", we can first check for condition 2:
=IF(SUMPRODUCT(--ISNUMBER(Q2:U2))>0,"∆","Does not contain X or dates")
A date in excel is literally a number with some decorative formatting. I am using ISNUMBER to find the numbers and SUMPRODUCT to count the identified cells in the range. If there are more than 0 (at least 1), then it will become ∆.
In place of "Does not contain X or dates" now, we could check for Os. I would count the Os and add the cells with - (conditions 3 and 5 together) and see if they add up to the total cells in Q2:U2 (which is 5 in this case):
=IF(COUNTIF(Q2:U2,"O")+COUNTIF(Q2:U2,"-")=5,"O","FALSE")
When combined, it would become:
=IF(COUNTIF(Q2:U2,"X")>0,"X",IF(SUMPRODUCT(--ISNUMBER(Q2:U2))>0,"∆",COUNTIF(Q2:U2,"O")+COUNTIF(Q2:U2,"-")=5,"O","FALSE"))
Since all these involve counts, it might be easier setting up helper columns, something like:
| Q | R | S | T | U | V | W | X | Y | Z
1 | | | | | | Count of X | Count of dates | Count of O | Count of - | Final value
2 | | | | | | A | B | C | D | E
A will be:
=COUNTIF(Q2:U2,"X")
B will be:
=SUMPRODUCT(--ISNUMBER(Q2:U2))
C will be:
=COUNTIF(Q2:U2,"O")
D will be:
=COUNTIF(Q2:U2,"-")
E will be:
=IF(V2>0,"X",IF(W2>0,"∆",X2+Y2=5,"O","FALSE"))
I'm trying to plot some data (standard curves for analytical chemistry) where the x axis is the mass of a compound I added to a solution, and the y axis is the signal recorded from an instrument (peak height on a mass spectrometer). I'd like Tableau to color code the data by compound (compound A, compound B, compound C, etc.), so that I'd wind up with a graph that looks something like this:
The original structure of my data was like this:
SampleID | Mass A | Mass B | ... | Signal A | Signal B | ...
standard 0 | 0| 0| ... | 0| 0| ...
standard 5 | 2.535| 2.555| ... | 0.494| 1.240| ...
standard 25| 12.675| 12.775| ... | 2.426| 7.235| ...
I know how to make graphs one compound at a time with these original data, but for the purposes of other analyses I'm doing with these data and because I want multiple compounds on the same graph, I've pivotted them so that the structure is now like this:
SampleID | Compound | Parameter | Value
standard 0 | A | Mass | 0
standard 0 | A | Signal | 0
standard 5 | A | Mass | 2.535
etc.
How do I make a graph where the mass is on the x axis, the signal is on the y axis, and the points are colored by compound? I don't see a good way to do it when my data are in this format. I've tried making new calculated variables where the value = NULL if the parameter is not equal to "Mass" and another calculated variable where the value = NULL if the parameter is not equal to "Signal" and then putting those pills on the columns and rows, but that's not working. Is there a way to do this in Tableau with data structured like this pivotted form?
Alternatively, is there a way to spread my pivotted data so that the new structure is like this:
SampleID | Compound | Mass | Signal
standard 0 | A | 0| 0
standard 5 | A | 2.535| 0.494
standard 25| A | 12.675| 2.426
standard 0 | B | 0| 0
etc.
and would that work better?
(For R users, that last bit would be the equivalent of the tidyr package gather and spread functions.)
To make the second structure appear like the third, add a calculated field called Mass defined as if Parameter = "Mass" then Value end. Do the same for Signal.
You can then hide the fields Parameter and Value if you like, and work with Mass and Value instead.
Put AVG(Mass) on the Columns Shelf and AVG(Signal) on the Rows shelf -- AVG, not ATTR. Then finally, put [Sample Id] on detail.
If I had to deal with this, I'd prefer to pre-process the data so that it has the format "SampleID | Compound | Mass | Signal", that would make Tableau chart straightforward.
I think there's a way to achieve the same with the data structure you have, but it's more tricky. So, if I understand correctly, you have the data it this form:
SampleId Compound Parameter Value
standard 5 A Mass 2.535
standard 5 A Signal 0.494
standard 5 B Mass 2.555
standard 5 B Signal 1.24
standard 25 A Mass 12.675
standard 25 A Signal 2.426
standard 25 B Mass 12.775
standard 25 B Signal 7.235
1) You can create calculated fields for Mass and Signal using level of detail expressions, that exclude the Parameter granularity:
Mass
{exclude [Parameter] : min(if [Parameter] = 'Mass' then [Value] else NULL end)}
Signal
{exclude [Parameter] : min(if [Parameter] = 'Signal' then [Value] else NULL end)}
That will "collapse" nulls in case Parameter is not included in the view.
2) Using the Scatter Plot visualization, you can pull Mass to columns and Signal to rows, add Compound to Color pane and SampleId to Detail pane. The plot will look like this:
This example should explain my question clearly
I have a huge table of values (50,000+ rows) in this format
PHRASE 1 | PHRASE 2 | VALUE
Sun | Blue | North
Moon | Green | South
Star | Red | West
I have a list of phrases in the format (again 50,000+ rows)
A B
1| Moon Fun Light Green |
2| Star Amazing Ball Red |
3| Sun Cat Inside Blue |
4| Star Dog Red Watch |
I need to search along the following lines - search A1 if you find a row where both PHRASE 1 & PHRASE 2 are present return the corresponding VALUE
Below is an example of how I would like the results would look. I.e. the search has checked to see if any of the word combos are present in the top table and returned the appropriate result if possible. There won't be an issue of two sets of positives i.e. Moon Fun and Light Green. The real values are all artist name and track name combinations.
A B
1| Moon Fun Light Green | South |
2| Star Amazing Ball Red | West |
3| Sun Cat Inside Blue | North |
4| Star Dog Red Watch | West |
A few notes:
The list of phrases to search are full of other text as well I.e. the cell will be the "The Moon was out tonight I was on the green hill". We need to search the phrase table, see if we find the combo of Moon & Green and if we do return the associated value.
I need to have multiple criteria in the search as a single search term doesn't narrow results enough, some of the words I'm searching are to general or are parts of other words (i.e. OFF is part of OFFLINE) which returns the wrong results where as searching OFF and another term simultaneously resolves that issue.
The list of phrases isn't in a set format, so I can't really exact all the values by splitting the columns i.e. it's not all "Moon - Green"
The closes I have come to solving this is using this formula:
IF(AND(ISNUMBER(SEARCH(C2,E2)),ISNUMBER(SEARCH(D2,E2))),B2,"")
Where C2 & D2 are the values to search, E2 is the box to search in & B2 is the value to return. The problem with this formula is that I'm limited to searching 1 combination at a time I.e. check C2 & D2 rather than saying check an array of C2:C100 & D2:D100
I've tried making that formula into an array with no luck.
I've also tried this formula:
=IFERROR(LOOKUP(2, 1/(ISNUMBER(SEARCH($L$7:$L$8, E2))), $K$7:$K$8),"")m
But in this situation it can only handle one critera (i.e. only search for Phrase 1) not both Phrase 1 and 2. $L$7:$L$8 is the list to search, E2 is the box to search in, $K$7:$K$8 is the corresponding value to return.
Hopefully that is enough to go on.
If you are happy to add an extra column to each dataset, then this will work:
Add an index column on your first table of values containing just a
number going from 1 to 50,000+
Add this array formula on your phrase sheet
{=SUM(ISNUMBER(SEARCH(L$2:L$50000,E2))*ISNUMBER(SEARCH(M$2:M$50000,E2))*P$2:P$50000)}
(where L and M are the columns containing your phrases and P is the index column)
Use the result of this column in a lookup.
As suggested below, if you can't (or don't want to) add a column to your first worksheet, you could change the formula to
{=SUM(ISNUMBER(SEARCH(L$2:L$50000,E2))*ISNUMBER(SEARCH(M$2:M$50000,E2))*ROW(L$2:L$50000))}
And use OFFSET to return the correct entry from your VALUE column.