I have a loop in latex, where I access 5 different tables to include in my document. The look has two elements - one variable indicating short name of the category (\n which can be A, O, I, R or H) and the variable that has the long name (\m, which can be "Apartment", "Office", etc).
This loop works as intended for caption and for input. But it does not work for "\label". In other words, the loop produces 5 tables, pulling the right files each time. It puts correct caption on these tables (Apartment, Office, etc), but \label does not get populated correctly. It produces only one label as "output_reg\n" instead of 5 labels as "output_reg_A", "output_reg_O", etc.
I would appreciate all the help I can get!
\documentclass{article}
\usepackage{tikz}
\begin{document}
\foreach \n\m in {A/Apartments,O/Office,R/Retail,I/Industrial,H/Hotel}
{ \begin{table}
\small
\centering
\caption{Regression results \n - \m } \label{output_reg_\n}
\begin{tabular}{ccccc}
a & a & \\
a & a &
\end{tabular}
\end{table}
}
content
% I want to be able to reference the tables as \ref{output_reg_A} and \ref{output_reg_O and so on.
\end{document}
Related
I'm kind of new to Access VBA and I’m having issues with my loop.
I have reviewed various books, websites, asked various friends. Currently I’m trying to have a user input two characters, and then if the two characters equal a certain combination then it is supposed to equal a numeric value, and then use the value in a distance calculation.
The user inputed values are strings and everything else is declared as double.
I have 200+ combinations that I am testing and have tried case statements, DLookup, do while, do until, if, and elseif loops with no success.
I'm also limited by IT and I’m unable to use DAO code.
Any assistance would be greatly appreciated.
I would first suggest creating a table to formally define the various character combinations and the corresponding value for each combination. This has the advantage that the combinations may be easily maintained going forward, rather than defining such combinations as part of queries or in VBA code.
Such a table could be as simple as containing three fields:
Character 1 (Text)
Character 2 (Text)
Value (Number)
You could then populate such a table with your valid combinations:
With the combinations rigorously defined, you have many options regarding how to prompt the user to enter the two characters and obtain the correponding value.
A very simplistic approach might be to use a form with three textboxes:
Here, the first two textboxes would be unbound, and might be called char1 and char2, and the third textbox might be called result and have a Control Source property equal to:
=DLookup("Value", "LookupTable", "char1 = '" & [char1] & "' and char2 = '" & [char2] & "'")
This would yield the following behaviour:
Consider using Access as a database and GUI application by storing your 200+ combinations in a table with corresponding numeric value. Then have an SQL query filter by user input and use resulting value for needed calculations. Below requires creating and using four Access objects: table, query, form, and module.
Table (tblCombinations)
id combn1 combn2 numeric_value
1 A B 150
2 C D 225
3 E F 100
4 G H 75
5 I J 200
...
SQL (no loops needed; using Access form control values)
SELECT c.combn1, c.combn2, c.numeric_value
FROM tblCombinations c
WHERE c.combn1 = Forms!myForm!myUserInputField1
AND c.combn2 = Forms!myForm!myUserInputField2
And even pass needed numeric value in distance calculation formula which can be a VBA function in a standard module:
SELECT c.combn1, c.combn2, Distance_Calculation(c.numeric_value) As distance_result
FROM tblCombinations c
WHERE c.combn1 = Forms!myForm!myUserInputField1
AND c.combn2 = Forms!myForm!myUserInputField2
VBA (place in standard module)
Public Function Distance_Calculation(num_value As Long) As Double
...
Distance_Calculation = some_value
End Function
You can use following type function in your result form button or after event on both textboxes-
Dim resultValue as Integer
If DCount("numeric_value", "tblCombinations", "[combn1] = '" & Forms!myForm!myUserInputField1 & "' and [combn2] = '" & Forms!myForm!myUserInputField2 & "'") > 0 then
resultValue = Dlookup("numeric_value", "tblCombinations", "[combn1] = '" & Forms!myForm!myUserInputField1 & "' and [combn2] = '" & Forms!myForm!myUserInputField2 & "'")
txtResult = Distance_Calculation(resultValue)
Else
Msgbox "No such combination exist. Kindly check combimation", vbinformation, "Information"
txtResult = 0
End if
I have a code below that works to take 24 columns (hours) of data and combine it into a single column array for each row in a dataframe:
# Adds all of the values into column twentyfourhours with "," as the separator.
agg_bluetooth_data$twentyfourhours <- paste(agg_bluetooth_data[,1],
agg_bluetooth_data[,2], agg_bluetooth_data[,3], agg_bluetooth_data[,4],
agg_bluetooth_data[,5], agg_bluetooth_data[,6], agg_bluetooth_data[,7],
agg_bluetooth_data[,8], agg_bluetooth_data[,9], agg_bluetooth_data[,10],
agg_bluetooth_data[,11], agg_bluetooth_data[,12], agg_bluetooth_data[,13],
agg_bluetooth_data[,14], agg_bluetooth_data[,15], agg_bluetooth_data[,16],
agg_bluetooth_data[,17], agg_bluetooth_data[,18], agg_bluetooth_data[,19],
agg_bluetooth_data[,20], agg_bluetooth_data[,21], agg_bluetooth_data[,22],
agg_bluetooth_data[,23], agg_bluetooth_data[,24], sep=",")
However, after this I still have to write more lines of code to remove spaces, add brackets around it, and delete the columns. None of this is difficult to do, but I feel like there should be a shorter/cleaner code to use to get the results I am looking for. Does anyone have any suggestions?
There is a built-in function to do rowSums. It looks like you want an analogous rowPaste function. We can do this with apply:
# create example dataset
df <- data.frame(
v=1:10,
x=letters[1:10],
y=letters[6:15],
z=letters[11:20],
stringsAsFactors = FALSE
)
# rowPaste columns 2 through 4
apply(df[, 2:4], 1, paste, collapse=",")
Another option, using #Dan Y's data (might be helpful if you posted a subset of your data using dput though).
library(tidyr)
library(dplyr)
df %>%
unite('new_col', v, x, y, z, sep = ',')
new_col
1 1,a,f,k
2 2,b,g,l
3 3,c,h,m
4 4,d,i,n
5 5,e,j,o
6 6,f,k,p
7 7,g,l,q
8 8,h,m,r
9 9,i,n,s
10 10,j,o,t
You can then perform the neccessary edits with mutate. There's also a fair amount of flexibility in the column selections within the unite call. Check out the "Useful Functions" section of the select documentation.
How can I put the text "100.000" in a table in Anychart? When I try to get the string "100.000" in, it is modified to "100".
For a working example see https://jsfiddle.net/Republiq/xcemvm9L/
table = anychart.standalones.table(2,2);
table.getCell(0,0).content("100.000");
table.container("container").draw();
If you want to use such number formatting for the whole table you can define numberLocale in the beginning. If the actual number is 100 and '.' - is a decimal separator and you want to show 3 zeros as decimals, put the following lines before creating the table:
anychart.format.locales.default.numberLocale.decimalsCount = 3;
anychart.format.locales.default.numberLocale.zeroFillDecimals = true;
And then put in the number as:
table.getCell(0,0).content(100);
If '.' - is a group separator and the actual number is 100000, put the following line:
anychart.format.locales.default.numberLocale.groupsSeparator = '.';
And then put in the number as:
table.getCell(0,0).content(100000);
If you want to use special format only for a single cell, we recommend you to use number formatter, which helps to configure all these options only for a single number. For example, it may looks like:
table = anychart.standalones.table(5,5);
table.getCell(0,0).content(anychart.format.number(100000, 3, ".", ","));
table.container("container").draw();
Also, you may learn more about this useful method and find examples in this article
A1
Michael Lewis
B1
'at'xyz
I would like an individual formula to do each of the following
Michael.lewis#xyz.com (First Name ‘dot’ Surname)
M.lewis#xyz.com (First initial ‘dot’ Surname)
mlewis#xyz.com (First initialSurname)
Id like a drop down menu to change which formula I am using.
Is this possible?
I'm not sure if I get exactly what you need, but here goes.
I had to translate all the formulas back to english because my work computer is in a different locale but I think it's right (in case there's a typo I missed)
The formulas you asked for in respective order:
(B11 = name, B12 = email domain)
=LEFT(B11;SEARCH(" ";B11)-1) & "." & RIGHT(B11; LEN(B11)-SEARCH(" ";B11))& "#" &B12
=LEFT(B11;1) & "." & RIGHT(B11; LEN(B11)-SEARCH(" ";B11))& "#" &B12
=LEFT(B11;1) & RIGHT(B11; LEN(B11)-SEARCH(" ";B11))& "#" &B12
Then you can just add a data validation list pointing to the cells you write the formulas on and it should work as intended, I hope.
Accessing first name in cell A1:
= LEFT(A1,FIND(" ",A1)-1)
Accessing last name in cell A1:
= RIGHT(A1,FIND(" ",A1)-1)
Accessing first initial in cell A1:
= LEFT(A1,1)
Getting passed the 'at' in cell B1 and only returning xyz:
= RIGHT(B1,5)
Therefore, for example, <first name>.<last name> is:
= LEFT(A1,FIND(" ",A1)-1)&"."&RIGHT(A1,FIND(" ",A1)-1)&"#"&RIGHT(B1,5)&".com"
If you remove the 'at' from cell B1 and just have xyz, then the formula above could be slightly simplified; You can substitute RIGHT(B1,5) simply with B1.
Also, the LOWER function converts all text to lowercase.
For example to get the lowercase first letter of first name, formula would be:
= LOWER(LEFT(A1,1))
I've got a set of data that I've arranged in an array within mathematica. The energy value should be as shown below when I copy as LaTex format:
Theta Phi Energy(Hartree)
1.5329 & -1.5708 & -2775.20972374594 \\
1.53476 & -1.25646 & -2775.209669993 \\
1.54014 & -0.942167 & -2775.20947403366 \\
What I'm actually getting when I copy:
1.5329 & -1.5708 & -2775.21 \\
1.53476 & -1.25646 & -2775.21 \\
1.54014 & -0.942167 & -2775.21 \\
I've done multiple data sets and have gotten it to work for all but one. There seems to be a set of 100 points that keep truncating. I've attempted the following code:
PESdatatable316 = {{"Theta", "Phi", "Energy(Hartree)"}};
Do[
PESdatatable316 = Append[PESdatatable316, {th316[[i]], phi316[[i]], NumberForm[energies316[[i]], 15]}], {i, 1, 30}]
TableForm[PESdatatable316]
where:
energies316 = Flatten[{energies100,energies216},1]
The issue seems to be within 'energies100'. The values were put in with 12 digits but truncate to 6 when I call the values.
Example:
energies100[[1]]
will output:
-2775.21
'NumberForm' corrects the values within mathematica but when I copy to LaTex form it reverts back to the truncated values.
Any ideas on how I can get these values to what they're supposed to be?
A solution has been found:
the use of 'TeXForm' with a 'NumberForm' nested inside results in the correct precision and can be copied with no issues arising.