I am trying to get equation numbers when knitting my .Rmd to .docx but I haven't found a way to get this or the labels to cross reference them to work. I tried this:
$$
P(L|C_L, C_R) = \frac {10^{\sum_{n=1}^ {4} (w_{c_{L,i}} - w_{c_{R,i}})}} {1+10^{\sum_{n=1}^ {4} (w_{c_{L,i}} - w_{c_{R,i}})}}
$$\label(#eq:left)
The probability for the left side winning can be calculated using \#ref(eq:left)
Which returns this:
Referencing correctly to the equation but the label for it doesn't show (having a (1) on the left or right of the equation) and instead, it prints out the text in the code.
Does anyone know what am I writing wrong here or if this is even possible to do for .docx files?
Thanks for your help
papaja extends bookdown, so the general approach you are trying is correct, but the syntax is a little off. Try the following:
\begin{equation}
P(L|C_L, C_R) = \frac {10^{\sum_{n=1}^ {4} (w_{c_{L,i}} - w_{c_{R,i}})}} {1+10^{\sum_{n=1}^ {4} (w_{c_{L,i}} - w_{c_{R,i}})}}
(\#eq:left)
\end{equation}
The probability for the left side winning can be calculated using \#ref(eq:left)
Note that equation references are not well supported in Word (i.e., apa6_docx()). See the here for details.
The within-document cross-referencing seems only to work with Bookdown output formats - i.e. word_document2 see here: https://bookdown.org/yihui/rmarkdown-cookbook/cross-ref.html
You could do use the pdf_document output and use the generic LaTeX reference for equations:
\begin{equation} \label{eq:left}
P(L|C_L, C_R) = \frac {10^{\sum_{n=1}^ {4} (w_{c_{L,i}} - w_{c_{R,i}})}}
{1+10^{\sum_{n=1}^ {4} (w_{c_{L,i}} - w_{c_{R,i}})}}
\end{equation}
with the following to put in the reference:
The probability for the left side winning can be calculated using
equation \ref{eq:left}.
The result will look like this (depending on the number of equations and sections):
The probability for the left side winning can be calculated using
equation 1
Related
I want this formula to calculate a date based on input from two other dates. I first wrote it for a single cell and it gives the expected results but when I try to use ARRAYFORMULA it returns the wrong results.
I first use two if statements specifycing what should happen if either one of the inputs is missing. Then the final if statement calculates the date if both are present based on two conditions. This seems to work perfectly if I write the formula for one cell and drag it down.
=IF( (LEN(G19)=0);(U19+456);(IF((LEN(U19)=0) ;(G19);(IF((AND((G19<(U19+456));(G19>(U19+273)) ));(G19);(U19+456))))))
However, when I want to use arrayformula to apply it to the entire column, it always returns the value_if_false if neither cell is empty, regardless of whether the conditions in the if statement are actually met or not. I am specifically talking about the last part of the formula that calculates the date if both input values are present, it always returns the result of U19:U+456 even when the result should be G19:G. Here is how I tried to write the ARRAYFORMULA:
={"Date deadline";ARRAYFORMULA(IF((LEN(G19:G400)=0);(U19:U400+456);(IF((LEN(U19:U400)=0);
(G19:G400);(IF((AND((G19:G400<(U19:U400+456));(G19:G400>(U19:U400+273)) ));(G19:G400);(U19:U400+456)))))))}
I am a complete beginner who only learned to write formulas two weeks ago, so any help or tips would be greatly appreciated!
AND and OR are not compatible with ARRAYFORMULA
Replace them by * or +
Try
={"Date deadline";ARRAYFORMULA(
IF((LEN(G19:G400)=0),(U19:U400+456),
(IF((LEN(U19:U400)=0), (G19:G400),
(IF((((G19:G400<(U19:U400+456))*(G19:G400>(U19:U400+273)) )),(G19:G400),
(U19:U400+456)))
))
)
)}
Keep in mind you cannot use AND, OR operators in an arrayformula, so you must find an alternative method such as multiplying the values together and checking them for 0 or 1 (true*true=1)
I am gathering based on your formula's and work that you want to have the following:
If G19 is blank show U19 + 456
If U19 is blank show G19
If G19 is less than U19 + 456 but greater than U19 + 273 show G19
Otherwise show U19 + 456
I'm not too sure what you want to happen when both columns G and U are empty. Based on your current formula you are returning an empty cell + 456... but with this formula it returns an empty cell rather than Column U + 456
Formula
={"Date deadline";ARRAYFORMULA(TO_DATE(ARRAYFORMULA(IFS((($G19:$G400="")*($U19:$U400=""))>0,"",$G19:$G400="",$U19:$U400+456,$U19:$U400="",$G19:$G400,(($G19:$G400<$U19:$U400+456)*($G19:$G400>$U19:$U400+273))>0,$G19:$G400,TRUE,$U19:$U400+456))))}
I have a column look like as below.
DK060
DK705
DK715
dk681
dk724
Dk716
Dk 685 (there is a space after Dk).
This is obviously due to human error. Is there any way that I can ensure the format is correct based on the specified format which is two uppercase DK followed by three digits?
Or Am I being too ambitious!!??
Go to the power query editor. Select advance editor and paste this 2 steps
#"Uppercase" = Table.TransformColumns(#"Source",{{"Column", Text.Upper, type text}}),
#"Replace Value" = Table.ReplaceValue(#"Uppercase"," ","",Replacer.ReplaceText,{"Column"})
Note: be sure to replace the "Source" statement into the Uppercase sentence for your previuos step name if needed.
So you will have something like this:
This is the expected result:
I've been trying to extract a (dynamic) bunch of words from an invoice. As this is the product description, it changes for each invoice. I tried to use the productnumber and a lookbehind, but that wouldn't always work, because there are other 6-8digitnumbers in the same invoice, is there a way to set the 6-8digitnumber and the date ahead also as a reference?
Description Productnumber Delivery Amount VAT Price excl. Price incl. Value excl. Value incl.
BenQ XL2430T (24", 1920 x 1080 Pixels) 2774800 21.11.2014 1 8.00% 323.15 349.00 323.15 349.00
LG Nexus 5X (32GB, Quarz, 5.20", Single SIM, 12.30Mpx, 4G) 5636609 03.03.2016 1 8.00% 276.85 299.00 276.85 299.00
So what I'd want to extract in this case is
BenQ XL2430T (24", 1920 x 1080 Pixels)
LG Nexus 5X (32GB, Quarz, 5.20", Single SIM, 12.30Mpx, 4G)
Is this even possible or am I trying the impossible?
As for code so far I extract the product number with:
\b\d{6,7}(?=\s+(?:0[1-9]|[12]\d|3[01])\.(?:0[1-9]|1[0-2])\.[12]\d{3})
but I just can't get around to include that in a lookahaed of the productnumber...
(that also only gives me the first result and I'd need the second product code extracted as well)
Hopefully this is understandable and it'd be much appreciated of somebody could help.
cheers
^(?!Description Productnumber)[\w\s(?,".]+\)?\s(?=[\d]{6,8})
Demo and explanation on syntax of the regex used:
https://regex101.com/r/HBvG3K/5
I have a series of values in Tableau that are long strings intermixed with letters and numbers. I am unable to control the data output, but would like to parse the names from these strings. They follow the following format:
Potato 1TByte 4.5 NFA
Board 256GByte 553 NCA
Launch 4 512GByte 4.5 NFA
Launch 4S 512GByte 4.5 NCA
From each of these, I am attempting to capture the following:
"Potato"
"Board"
"Launch 4"
"Launch 4S"
Each string follows the same format: the name, followed by size, followed by some extra information we don't really care about.
I've tried to put together some text parsing strings, but am coming up short, and am still trying to learn regular expressions.
The Tableau calculated field I was trying to work with was something like the following:
LEFT([String], FIND([String], "Byte") - 2)
The issue is that the text and numbers preceding Byte can be anywhere from 4 to 2 characters and I need a way to identify the length of that.
Any help would be greatly appreciated!
One option which uses a regex replacement:
REGEXP_REPLACE('Launch 4 512GByte 4.5 NFA', ' \d+[A-Z]Byte .*$', '')
This strips off everything from the Byte term to the right, leaving us with only the product name.
You could try the following - this seems to work - Screenshot of Tableau output. Find below the formulas for the various derived columns you see in the screenshot (Your source column is called [Name])
Step1 = LEFT([Name],FIND([Name],"Byte")-1)
Step2 = LEN([Step1])-LEN(REPLACE([Step1]," ",""))
Step3 = FINDNTH([Step1]," ",[Step2])
Step4 = LEFT([Step1],[Step3]-1)
And of course you can nest all these in a single calculated field - kept them as separate columns for easier understanding
I am using a infragistics ultrawingrid and am trying to use formula in one of my columns. I have used many formulas and they all work but now I am running into an issue when the actual column name would be something like bla bla bla (Y or N) so my formula would look like the following:
e.Layout.Bands(0).Columns("Tax").Formula = "IF([Includes Tax (Y or N)]<>'Y',[Unit Price]*0.0825,0)"
and I get an error - I would guess it would be the () in the formula - how do I use these in a formula?
You are getting #REF! error because the CalcManager tries to evaluate incorrectly the text inside the parentheses "()".
More information about the usage of the Formulas could be found at the Formula Syntax paragraph.
In your case since parentheses are part of the name of your column you would have to escape them, so that way, the CalcManager won't try to evaluate them anymore, and you can do that by using the following way to set your Formula instead:
e.Layout.Bands(0).Columns("Tax").Formula = "IF([Includes Tax \\(Y or N\\)]<>'Y',[Unit Price]*0.0825,0)"