Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
 Using VBA in Excel to run formulas - Formulas not working until reference cell activated Use an array formula instead of cell by cell formula. That way you enter the formula once for the whole range. See here: http://office.microsoft.com/en-us/excel-help/introducing-array-formulas-in-excel-HA001087290.aspx for details. Do it by hand while recording a macro then adapt the code as needed. Categories : Excel Convert HTML-Strings to LaTex using pypandoc If you check pypandoc sources you see that convert just runs pandoc process with proper input and output streams. The error happens when pandoc command is not found. Probably you installed pypandoc and forget about pandoc itself. Or the command is out of your shell PATH. Categories : Python R evalute formulas in a list of formulas gsub is for character strings, not for language objects. (and note that a formula is class of object in R (not what you have here) If you want to calculate the values (results) given a set of parameters use eval. If you want to substitute in the values and return language objects, it will take some do.call, substitute, trickery # a smaller example l <- list(quote(-(1/(C1 * Rf) + (1/(C1 * Rc) + (1/(C1 * Ree) + 1/(C1 * Rei))))) ,quote(1/(C1 * Rei)), 0) ATi <- list(C1 = 0.11054601, Ra = 0.04522716, Rc = 9.95953827, Ree = 1.65135221, Rei = 7.17513804, Rf = 285.65809505) # to find result use eval sapply(l, eval, env= ATi) # [1] -7.678626 1.260743 0.000000 # to substitute values for symbols lapply(l, func Categories : R How can I go through all the formulas and array formulas of a worksheet without repeating each array formula many times? You basically need to keep track of what you've already seen. The easy way to do that is to use the Union and Intersect methods that Excel supplies, along with the CurrentArray property of Range. I just typed this in, so I'm not claiming that it's exhaustive or bug-free, but it demonstrates the basic idea: Public Sub debugPrintFormulas() Dim checked As Range Dim c As Range For Each c In Application.ActiveSheet.UsedRange If Not alreadyChecked_(checked, c) Then If c.HasArray Then Debug.Print c.CurrentArray.Address, c.FormulaArray Set checked = accumCheckedCells_(checked, c.CurrentArray) ElseIf c.HasFormula Then Debug.Print c.Address, c.Formula Set checked = accumCheckedCells_(chec Categories : Excel What is the difference of tex-mode and latex-mode and LaTeX-mode in emacs The modes provided by AUCTeX are listed at https://www.gnu.org/software/auctex/manual/auctex.html#Modes-and-Hooks and they are plain-TeX-mode LaTeX-mode ams-TeX-mode ConTeXt-mode Texinfo-mode docTeX-mode Instead, tex-mode plain-tex-mode latex-mode slitex-mode doctex-mode (note the different capitalization) are the major modes provided by the TeX mode package shipped with Emacs. If you want to open all *.tex files with AUCTeX LaTeX mode add this to your .emacs: (add-to-list 'auto-mode-alist '("\.tex$" . LaTeX-mode)) Actually, this shouldn't be necessary, because AUCTeX defines the tex-mode.el mode names as alias of its own modes. Categories : Emacs Is there a DSL for expressing formulas? Since your constraint is that the formula runs both locally in the browser and on the server, you're stuck with the intersection of languages that compile to, or can be interpreted by, both js and your desired server language (in this case Go) - which is basically nothing. IMO your current approach makes perfect sense - why not continue using node? You have a pretty much perfect separation of concerns with the formula code. If it's a performance issue, check out this list of other server languages that can compile to js Of these, I like the Haxe project, but unfortunately it doesn't target Go. And it also adds a layer of abstraction that your current approach doesn't have or need. If you want to use a scripting language instead of a compilation target you could write the formulas in Lu Categories : Javascript Array of formulas You can achieve this with an array of blocks. Each block would receive a parameter x and return a value, calculating one function of yours. Then, you can select any position of the array and execute it. It will be something like this: typedef CGFloat (^MyFunction)(CGFloat); //using a typedef to ease the heavy syntax of the blocks MyFunction function1 = ^CGFloat(CGFloat x){ return x + 5; }; MyFunction function2 = ^CGFloat(CGFloat x){ return x - 5; }; MyFunction function3 = ^CGFloat(CGFloat x){ return x / 5; }; MyFunction function4 = ^CGFloat(CGFloat x){ return x * 5; }; NSArray *functions = @[function1, function2, function3, function4]; Now you can access any position of the array, and execute the chosen block, like this: MyFunction myFunction = functions[3]; C Categories : IOS How to use formulas from a text file? Yes this is an good idea . But data type will make problem if you getting them from a text file . You also need good validation for that . As per my advice you have to use XML for that . It easy to handle and you can pick more accurate data as compare text file Categories : C# Speed up Excel formulas I don't think that there is really a chance to speed up Excel Formula. But you could save your File in binary code (.xlsb). Losing some compatibility but improving performance. You also could stop auto (re-)calculations of ther Formula, then you have to manualy refresh. This will let you edit the file much smoother. Categories : Excel Run predefined formulas in R with one function Is this what you want? data(mtcars) F1 <- formula(mpg ~ cyl + disp) F2 <- formula(mpg ~ cyl + hp) F3 <- formula(mpg ~ cyl + wt) F4 <- formula(mpg ~ cyl + qsec) All.formulas <- list(F1, F2, F3, F4) All.models <- lapply(All.formulas,lm,data=mtcars) lapply(All.models,summary) Formulas are not really models. The solution with apparent regression calls: customF <- function(x) { out.model <- lm(x,data=mtcars) out.model$call <- x return(out.model) } All.models <- lapply(All.formulas,customF) lapply(All.models,summary) There probably is a more elegant way to do it, but this works too. Categories : R Defining and using names in VBA formulas To answer the direct question, pass a Range (not a String) to RefersTo, like this ActiveWorkbook.Names.Add Name:="dates", RefersTo:=Selection That said, you should not use Select/Selection for code like this. See this answer for some examles of how to avoid these. Categories : Excel Using VBA, copy all formulas from one sheet to another and nothing else? How about: Sub dural() Dim r As Range, ady As String For Each r In Sheets("Sheet1").Cells.SpecialCells(xlCellTypeFormulas) ady = r.Address r.Copy Sheets("Sheet2").Range(ady) Next End Sub Categories : Excel Copy cells with formulas in macro After inserting a new row 2 (so that it's contents are now on row 3), I would copy row 3 back to row 2 (basically make a duplicate), and then override the values with the data you want to move from sheet 'Enter Trade' range B2:B20, like so: Sub Trade_Button_Click() Dim btn As Button Dim wsEntry As Worksheet Dim wsTrades As Worksheet Set wsEntry = Sheets("Enter Trade") Set wsTrades = Sheets("Trades") Set btn = wsEntry.Buttons(Application.Caller) wsTrades.Rows(2).Insert wsTrades.Rows(3).Copy wsTrades.Rows(2) With Intersect(wsEntry.Range("A2", wsEntry.Cells(Rows.Count, "A").End(xlUp)).EntireRow, wsEntry.Columns(btn.TopLeftCell.Column)) wsTrades.Range("A2").Resize(, .Rows.Count).Value = Application.Transpose(.Value) End With Set wsTrades Categories : Excel How to filter formulas based on dates? You can combine logical operators and dates like so. =COUNTIF(B20:B25,">8/5/2013") For example the above code counts the number of cells in the range B20:B25 with a data greater than 8/5/2013 =COUNTIFS(B10:B15,">=8/6/2013",B10:B15,"<=8/25/2013") This one counts the number of cells in the range B10:B15 that are between (inclusive) 8/6/2013 and 8/25/2013. Categories : Excel Getting numbers computed with formulas with XLConnect I ran into the same problem. Have you looked at the parameter 'useCachedValues' for the readWorksheet function? Here is the help doc on the parameter: useCachedValues logical specifying whether to read cached formula results from the workbook instead of re-evaluating them. This is particularly helpful in cases for reading data produced by Excel features not supported in XLConnect like references to external workbooks. Defaults to FALSE, which means that formulas will be evaluated by XLConnect. I specified useCachedValues=TRUE. While the formulas in my case did not involve references to external links, this worked for me and I was able to read in the values. Categories : R Using GMP to calculate very large Integers from formulas Question 1 Long double allows to handle larger numbers than double (both in the exponent and in the significand precision). But you have to think that your 1e308 order of magnitude doesn't mean anything if your goal is to store large integers; you only have to care about the size of the significand precisions, either 52/53 bits (double) or 64 bits (x86 extended precision). If you try to use it with larger integers, you will have a correct order of magnitude but the exact value will be lost (when computing with integer numbers, people generally care a little more about this than when playing with approximate numbers). Question 2 Using GMP is a nice choice. Other libraries also exist; for smaller values I use a lot the libqd which has an extended fixed precision and are very quick but this Categories : C Need help regarding array formulas implementation in apache poi api I am not sure how you have use the formula yet. However if your problem is regarding the dynamic cell reference based on rows and Columns, perhaps I can help you. For any cell, say "B5", at runtime, cell.getReference(); will give you cell reference (like in example... it will return you "B5" cell.getReference().toString().charAt(0); will give you the Column Reference (will give you "B" if the current cell is B5). Now cell.getRowIndex(); OR cell.getReference().toString().charAt(1); will give you Row Index. I have used that multiple times to update/create the Named ranges and formula on my workbook. Small Changes to include handling address like AZ89 For the cases of AZ99 we can use for this we can use small hacks like: String str = cell.getReference(); for(index Categories : Java Any pitfalls to using programatically constructed formulas? I'm always hesitant to claim there are no situations in which something involving R environments and scoping might bite, but ... after some more exploration, my first usage above does look safe. It turns out that the printed call is a bit of red herring. The formula that actually gets used by other functions (and the one extracted by formula() and as.formula()) is the one stored in the terms element of the fit object, and it gets the actual formula right. (The terms element contains an object of class "terms", which is just a "formula" with a bunch of attached attributes.) To see that all of the proposals in my question and the associated comments store the same "formula" object (up to the associated environment), run the following. ## First the three approaches in my post formula(f Categories : R Combining concatenate and if in Excel formulas I think this is what you're looking for: =IF('Unapplied Report'!A5="","",TEXT('Unapplied Report'!A5,"0000"))&IF('Unapplied Report'!C5="","",TEXT('Unapplied Report'!C5,"0000"))&IF('Unapplied Report'!D5="","",TEXT('Unapplied Report'!D5,"0000")) Categories : Excel Excel VBA changing my formulas in a table? I faced a similar issue. Ideally you could tell excel to stop doing this but I haven't been able to figure out how. Supposedly doing the following is supposed to keep excel from copying the formulas: xlApp.AutoCorrect.AutoFillFormulasInLists = false but it didn't work for me. Using the answer from this question How to create running total using Excel table structured references? helped me. It doesn't feel like the ideal solution but it does do the job. I used this formula where Weight is a column name from my table. #This Row is a "Special item specifier" and has a special meaning. The syntax looks a little funky because it's what's called a Structured Reference: =AVERAGE(INDEX([Weight],1):[[#This Row],[Weight]]) The INDEX([Weight],1) part gives the reference for the 1st row i Categories : Excel How can I set up a new keyword in LaTeX-mode I have AUCTeX installed. Here are some examples -- the second set of quotations would be empty instead of a wavy or square bracket. I personally prefer to define my own font faces and my own keywords, which is a different format. ;; EFFECT{[font-lock-function-name-face]} (setq font-latex-match-function-keywords '( ("newcommandx" "*|{\[[{") ) ) ;; EFFECT{[font-lock-constant-face]} (setq font-latex-match-reference-keywords '( ("fancypagestyle" "[{") ("fancyfoot" "[{") ) ) ;; EFFECT{[font-lock-type-face]} (setq font-latex-match-textual-keywords '( ("parentext" "{") ("hybridblockquote" "[{") ("parskip" "") ) ) ;; EFFECT{[font-lock-variable-name-face]} (setq font-latex-match-variable-keywords '( ("new Categories : Emacs LaTeX in the web (equations enumeration) According to the documentation, you need to turn this on explicitly like so: MathJax.Hub.Config({ TeX: { equationNumbers: { autoNumber: "AMS" } } }); This will give you AMS-style numbering. You can also specify "all" to number every displayed equation. Categories : HTML Run a local LaTeX service This might point you into the right direction: http://alex.nederlof.com/blog/2013/02/22/latex-build-server/ . In case you want to show mathematcal formulas in the editor only, you don't need a LaTeX server. You may use the MathML notation. MathML is a standart implemented by HTML5 (Firefox, Opera and Chrome (and IE10, IE9 with AddOn) support it). To make it work you will have to add the MathML tags to the tinymce configuration parameters valid_elements and valid_children. Here are some helpfull links to get you started: http://www.mozilla.org/projects/mathml/start.html http://en.wikipedia.org/wiki/MathML http://www.w3.org/Math/ Categories : Web Services Openpyxl: Formulas getting removed when saving file openpyxl does currently not support reading of formulas. Ie. If you read your file and write it back, all formulas are removed. There is an active feature request in bitbucket tough. Categories : Python input box to populate excel formulas in a file Unfortunately what you want to do can't be done without implementing a part of the spreadsheet program (Excel) in your code. There are no shortcuts there. As for the file format, Python can deal natively with the CSV files, but I think you'd have trouble importing raw formulas (as opposed to numeric or textual content) from CSV into Excel itself. Since you are already into Python, maybe it would be a better idea to move you logic from the spreadsheet into the program: use Excel or other spreadsheet program to input your data, just the numbers, and use your script not to modify the sheet, but to effect the calculations you need - maybe storing the data in a SQL database (Python s built-in SQLite will perform nicely for a single user app like in this case) - and output just the calculate Categories : Python Dynamic charts using formulas only (i.e. without named ranges and VBA) Short Answer: No Longer answer: If you have the name function pointing to parameters on your spreadsheet, that would be as easy to maintain as having the ranges in text on your spreadsheet. E.G. Name Data1 can be defined as =Offset(Indirect(B1),0,0,B2,0), where the sheet looks like this: Data Location Sheet1!A7 Data Points 5 Also, the definition of your title defines how many points are seen, so even if you have the data defined as 5 point as in the example, if your titles only have 3 points, then only 3 points will be seen Categories : Excel How to store formulas, instead of values, in pandas DataFrame This will work in 0.13 (still in development) In [19]: df = DataFrame(randn(10,2),columns=list('ab')) In [20]: df Out[20]: a b 0 0.958465 0.679193 1 -0.769077 0.497436 2 0.598059 0.457555 3 0.290926 -1.617927 4 -0.248910 -0.947835 5 -1.352096 -0.568631 6 0.009125 0.711511 7 -0.993082 -1.440405 8 -0.593704 0.352468 9 0.523332 -1.544849 This will be possible as 'a + b' (soon) In [21]: formulas = { 'c' : 'df.a + df.b' } In [22]: def update(df,formulas): for k, v in formulas.items(): df[k] = pd.eval(v) In [23]: update(df,formulas) In [24]: df Out[24]: a b c 0 0.958465 0.679193 1.637658 1 -0.769077 0.497436 -0.271642 2 0.598059 0.457555 1.055614 3 0.290926 -1.617927 -1.327001 4 -0.248910 -0 Categories : Python Simple excel find and replace for formulas If the formulas are identical you can use Find and Replace with Match entire cell contents checked and Look in: Formulas. Select the range, go into Find and Replace, make your entries and `Replace All. Or do you mean that there are several formulas with this same form, but different cell references? If so, then one way to go is a regular expression match and replace. Regular expressions are not built into Excel (or VBA), but can be accessed via Microsoft's VBScript Regular Expressions library. The following function provides the necessary match and replace capability. It can be used in a subroutine that would identify cells with formulas in the specified range and use the formulas as inputs to the function. For formulas strings that match the pattern you are looking for, the function Categories : Excel Latex Citation in matplotlib Legend This can be done using the matplotlib pgf backend for python. The python file for generating the graph is as follows: import numpy as np import matplotlib as mpl mpl.use('pgf') import matplotlib.pyplot as plt x = np.linspace(0., 1., num=100) y = x**2 plt.plot(x, y, label=r'Data cite{}') plt.legend(loc=0) plt.savefig('fig.pgf') The pgf file can then be utilized in a latex paper as such: documentclass[letterpaper,10pt]{article} usepackage[utf8x]{inputenc} usepackage{pgf} egin{document} egin{figure} centering input{fig.pgf} caption{Test Figure} end{figure} end{document} Whenever the latex file is compiled, the citation in the legend will be updated automatically. Categories : Python Latex and Sweave, cannot include figure Create a file master.Rnw that contains nothing but the LaTeX setup (packages to be used, geometry, title, begin/end document, bibliography style and file......) If you need to use R functions in various places in your paper, create a file func.Rnw where you create these functions. Make this file the first to SweaveInput{func.Rnw} in your master.Rnw - see here for details Now create one file for each "unit" of your paper (chapter, section, whatever you like). Make them all chapX.Rnw files, whether they contain R code or not. SweaveInput{chapX.Rnw} them in the desired order in your master.Rnw file. At any time during the process, run Sweave("master.Rnw") in R and then pdflatex master.tex from the console to see what you have produced. Categories : R Regex to edit latex tables An example with Python: #!/usr/bin/python import re data = r'''documentclass[letter]{article} usepackage{amsmath, amsthm, amssymb} % Additional math packages egin{document} egin{table}[hptb] egin{center} egin{tabular}{|l||c|c|c|c|c|c|c|} hline (Intercept)&$underset{(1.742)}{-9.686}$&$underset{(0.907)} {-9.085}$&$underset{(0.663)}{-9.724}$&$underset{(0.565)}{-9.077}$&$underset{(0.619)} {-7.601}$&$underset{(0.838)}{-5.273}$&$underset{(1.120)}{-3.417}$\ end{tabular} end{center} end{table} end{document}''' print re.sub(r'(\underset{()(-?[0-9]+(?:.[0-9]+)?)()}s*{)(-?[0-9]+(?:.[0-9]+)?)(?=}\$)', lambda m: m.group(1)+m.group(2)+m.group(3)+'\bf{'+m.group(4)+'}' if abs(float(m.group(4))/float(m.group(2)))>2 else m.group(0), data) In sho Categories : Regex Disable latex symbol conversion in vim This functionality is provided by Vim's "conceal" feature. Vim's TeX plugin takes advantage of "conceal" if you have set 'conceallevel' to 2. See :h ft-tex-syntax. Leave 'conceallevel' at its default value of 0 to disable concealing. Alternatively, put the following line in your vimrc. let g:tex_conceal = "" Categories : Vim Compiling a LaTeX document from C++ program First, the path to the programs latex and dvipdf needs to be in your PATH environment variable. Second, the calls of the shell via system are totally independent (in fact a new instance of the shell is started each time). So if you switch the directory in one, this does not affect the others. Switch instead the current directory of your program via: chdir(directory.c_str()) You need for this #include using namespace std; at the beginning of the file. Please note that system calls with command lines depending on input parameters can be easily exploited to run arbitrary commands if the parameters (in your case the filename) are not carefully checked. As you do not have quotes, the program fails if there are e.g. whitespaces in the filename. Categories : C++ How to get LaTeX to work in IPython notebook? If you want to write latex you should write in in a Markdown cell, not in a code cell. Still, consider migrating to 0.13, 0.12 cannot read notebook generated from newer version and has a design flaw in notebook format. Categories : Ubuntu xtable() to preserve latex function in R Two things are needed; first, double the backslash, and second, turn off the usual text sanitizing function by passing identity (which just returns the input). > x <- as.vector(rbind(1, paste("\frac{",1, "}{", 2, "}", sep ="" ))) > y <- as.vector(rbind(2, paste("\frac{",2, "}{", 3, "}", sep ="" ))) > print(xtable(cbind(x,y)), sanitize.text.function=identity) % latex table generated in R 3.0.1 by xtable 1.7-1 package % Wed Jul 3 10:17:21 2013 egin{table}[ht] centering egin{tabular}{rll} hline & x & y \ hline 1 & 1 & 2 \ 2 & frac{1}{2} & frac{2}{3} \ hline end{tabular} end{table} Categories : R Numpy 2d and 1d array to latex bmatrix When you do this: for line in array: you are iterating over the first dimension of array. When the array is 1-D, you end up iterating over the values. You need to ensure that array is really 2-D before doing this iteration. One way is to pass the argument through numpy.atleast_2d: import numpy as np def array_to_bmatrix(array): array = np.atleast_2d(array) begin = '\begin{bmatrix} ' data = '' for line in array: etc. Categories : Python Latex as copyable text not as image If you are using Firefox, you can install a browser AddOn called "Web Developer" which will give you an added menu bar. One of the commands available from this bar is CSS/Display Style Information. You can then select any element on the page and the styling for the element will be shown in separate window at the bottom of the page. By using this, you can potentially reconstruct from scratch the HTML styling for a particular element or set of elements. Categories : HTML python latex font xcode I usually find it easiest to directly specify the font file I'm after. Here's an example: import matplotlib.pyplot as plt import matplotlib.font_manager from numpy import * # cmunso.otf is a randomly selected font in my tex installation path = '/usr/local/texlive/2012/texmf-dist/fonts/opentype/public/cm-unicode/cmunso.otf' f0 = matplotlib.font_manager.FontProperties() f0.set_file(path) plt.figure() plt.xlim(0,1.) plt.ylim(0,1.) d = arange(0, 1, .1) plt.plot(d, d, "ob", label='example') plt.text(.5, .1, 'text.. abcdef', fontproperties=f0, size=30) plt.xlabel("x label", fontproperties=f0) plt.legend(prop=f0, loc=2) I'm not a font expert, but I think the reason this is easier is that font selection often has a cascading set of defaults for when the way you specify the font doesn Categories : Python Export a table to LaTeX and respect ^:nil I get it to export successfully under Org 8.0.3. Export section*{tRemovalEpisodes} label{sec-1} A "removal" is a discrete event blah blah blah. This is all fine. underline{Columns} egin{itemize} item removal\_id (int) is a Primary Key item child\_id (int) is a Foreign Key item removal\_date (date) item exit\_date (date) item primary\_removal\_reason (int) end{itemize} egin{center} egin{tabular}{r|r|r|r|r|} removal\_id & child\_id & removal\_date & exit\_date & primary\_removal\_reason\ hline 1 & 12345 & 2012-01-01 & 2012-04-13 & 13\ 2 & 12346 & 2012-01-03 & 2013-02-14 & 22\ 3 & 12347 & 2012-04-02 & & 12\ 4 & 12348 & 2012-09-05 & 2013-02-28 & 13\ 5 & 12349 & 2013-01-02 & 2013-04-12 & 56\ Categories : Emacs LaTeX or MathML to an image on Android I think there was a similar discussion: LateX rendering for both Java and Objective C Maybe mathjax helps? http://www.mathjax.org/ Categories : Android