Find intermediate color - colors

I have 2 colors #DCE7FA and #CADBF7. Want the intermediate color(a kind of Arithmetic mean).
Hexadecimal arithmetic median does not work.
How to proceed?

Yes the normal hex median wont work.. !!
try spliting to to R, G , B and find individual medians..
r1 = DC ; r2 = CA
g1 = E7 ; g2 = DB
b1 = FA ; b2 = F7
now find individual medians..
now,
r3 = (r1+r2)/2 = D3 ;
g3 = E1
b3 = F5
now ur intermediate color = #D3E1F5..

Found an online tool:
http://www.colortools.net/color_combination.html

Related

Excel to return a value in a cell after checking a range of cells

In Excel I have a range of cells; for simplicity say three columns A1:A3 containing either the letter P, M or D. I would like to be able to check this range of cells and display in cell A4 either P, M or D depending on the frequency of the letters (see below for example of intended results). Need all cells as D to result in D. Its to track student grades, Pass (lowest denominator), Merit and Distinction.
PPP = P; PMP = P; MPP = P; PPM = P; MMM = M; MDD = M; MMD = M; DMM = M; DDD = D; PMD = P
Use this:
=IF(COUNTIF(A1:A3,"P"),"P",IF(COUNTIF(A1:A3,"M"),"M","D"))

Approximate within range Excel?

This is the general formula needed: if((b2-b1)=c1,True,False
However, I need b2-b1 to approximately equal c1, within 5 or so units (in this case seconds). Is there a function that could handle this?
You can also try this:
=ABS(B2-B1-C1)<=5
I think this should help you:
=AND(B2 - B1 >= C1 - 5, B2 - B1 <= C1 + 5)
This will return TRUE/FALSE only. You don't need to put IF if you don't want to type expressions.
=if(and( (b2-b1) >= c1 - 5, (b2-b1) < = c1 + 5 ), true, false)

Muliple IF AND statement excel

I am trying to write a formula and getting error. The logic is:
If A1 > 0 and B1 = "PEN" Output = "Refund 1"
If A1 > 0 and B1 = "INT" Output = "Refund 1"
If A1 > 0 and B1 = "ADM" Output = "Refund 1"
If A1 > 0 and B1 = "AB" Output = "Refund 2"
If A1 < 0 and B1 = "PEN" Output = "Fund 1"
If A1 < 0 and B1 = "INT" Output = "Fund 1"
If A1 < 0 and B1 = "ADM" Output = "Fund 1"
If A1 < 0 and B1 = "AB" Output = "Fund 2"
I am getting errors writing multiples If-statements.
Can someone help?
This will work for you.
=IF(AND(A1>0,OR(B1="PEN",B1="INT",B1="ADM")),"Refund 1",IF(AND(A1>0,B1="AB"),"Refund 2",IF(AND(A1<0,OR(B1="PEN",B1="INT",B1="ADM")),"Fund 1",IF(AND(A1<0,B1="AB"),"Fund 2"))))
While #Jeanno's answer works for this case, I wanted to point out that you can accomplish the same thing more generally using a lookup table.
Items in blue are hard-coded, black are formulas.
There are a couple advantages to doing it this way:
Extensible: if your criteria suddenly grew from testing two conditions to 3 or more, the IF style statement is going to go from almost illegible to completely illegible.
Clear: By looking up the value on a table, anyone can tell why a row is getting assigned to the result. Trying to do that with Excel's nested AND, OR, IF statements is really hard.

R - type in multiple strings without quotation marks

I need to type in a vector of strings. Each element is a variable name to be used in a later loop. It's a pain to type in all the quotation marks and commas -- is there a way to just type it like so (this is something I can do in Stata):
balance.vars <- c(a3 a4 a5_1 a5_2 a5_3 a6_1 a6_2 a6_3 a6_4
a6_5 a6_6 a8 a8_1 a8_2 a8_3 a9 a9_3
a10_1 a10_2 a10_3)
etc.
You can use scan with text:
balance.vars <- scan(text='a3 a4 a5_1 a5_2 a5_3 a6_1 a6_2 a6_3 a6_4
a6_5 a6_6 a8 a8_1 a8_2 a8_3 a9 a9_3
a10_1 a10_2 a10_3',what='char')
But I would avoid to use many separated variables like this. What not to use a vector or a list? Maybe ifyou explain better your workflow and what do you want to do we can propose more R-style solution.
You can also use paste to create such list, for example:
paste(paste0('a',rep(3:10,each=3)),rep(0:3,8),sep='_')
EDIT after OP clarification, it seems he wants to filter a data.frames variables.
varnames <- colnames(d)[grepl('^a[0-9]+(_[1-3])?',colnames(d))]
formulas <- paste(varnames, "group", sep = " ~ ")
res <- lapply(formulas, function(f) t.test(as.formula(f), data = d))
R doesn't support this style for function calls. But if you put all the variable names in a text file (one per line), like this:
a3
a4
a5_1
a6_1
etc.
You can then do:
balance.vars <- scan('varnames.txt', what='')
and not have to type all those quotation marks and commas.
How about:
balance.vars <- unlist(strsplit("a3 a4 a5_1 a5_2 a5_3 a6_1 a6_2 a6_3 a6_4 a6_5 a6_6 a8 a8_1 a8_2 a8_3 a9 a9_3 a10_1 a10_2 a10_3", " "))
or:
balance.vars <- unlist(strsplit("a3 a4 a5_1 a5_2 a5_3
a6_1 a6_2 a6_3 a6_4 a6_5 a6_6 a8 a8_1 a8_2 a8_3 a9 a9_3
a10_1 a10_2 a10_3", "\\W", perl=TRUE))
if you want to use line breaks to improve readability. :-)
Using the qdap package:
library(qdap)
qcv(terms="a3 a4 a5_1 a5_2 a5_3 a6_1 a6_2 a6_3 a6_4
a6_5 a6_6 a8 a8_1 a8_2 a8_3 a9 a9_3
a10_1 a10_2 a10_3")

C# Negative IP Address to dotted decimal using intel standards conversion

I would like to have some help on this since I've been spending hours to do it, but I couldn't. I want to write a function that takes signed integer and convert it to a dotted IP address using Intel standard algorithm, here is an example:
the IP address 192.168.18.188 displays as -1139627840. To convert this IP address using Intel standards, I will have to perform the following procedure:
Convert (-1139627840) to a hex value. BC12A8C0.
Reverse the hex bytes, as shown below: CO A8 12 BC
Convert the bytes from hex to decimal, as shown below: 192 168 18 188
The IP address displays in the following format: 192.168.18.188
Any help would be appreciated.
I know this doesn't answer your question in regards to the Intel Standard, but just to throw it out there (in case you're trying to reinvent the wheel), you can convert an int to an IP like this:
string ip = new IPAddress(BitConverter.GetBytes(-1139627840)).ToString();
The magic is in combining:
the >> operator, which shifts the bits in a number to the right
the & operator, which does a bit-wise and (the more common && does a logical and)
So something like this:
var number = -1139627840;
var b1 = number & 255;
var b2 = (number >> 8) & 255;
var b3 = (number >> 16) & 255;
var b4 = (number >> 24) & 255;
Console.WriteLine(string.Format("{0}.{1}.{2}.{3}", b1, b2, b3, b4));

Resources