In R formulas, why do I have to use the I() function on power terms, like y ~ I(x^3)

The tilde operator is actually a function that returns an unevaluated expression, a type of language object. The expression then gets interpreted by modeling functions in a manner that is different than the interpretation of operators operating on numeric objects. The issue here is how formulas and specifically the “+, “:”, and “^” operators in … Read more

Concatenate column headers if value in rows below is non-blank

UseĀ¹ the following as an array formula. =TEXTJOIN(“–>”, TRUE, IF(LEN(C3:I3), C$2:I$2, “”)) Pre-Excel 2016 versions While you could just string together a series of IF statements, a cleaner alternate might be to write a user defined function (aka UDF). In a standard VBA module code sheet: Function udf_Stitch_Together(r As Range, _ h As Range, _ … Read more

Get formula from Excel cell with python xlrd

[Dis]claimer: I’m the author/maintainer of xlrd. The documentation references to formula text are about “name” formulas; read the section “Named references, constants, formulas, and macros” near the start of the docs. These formulas are associated sheet-wide or book-wide to a name; they are not associated with individual cells. Examples: PI maps to =22/7, SALES maps … Read more

How to do a fractional power on BigDecimal in Java?

The solution for arguments under 1.7976931348623157E308 (Double.MAX_VALUE) but supporting results with MILLIONS of digits: Since double supports numbers up to MAX_VALUE (for example, 100! in double looks like this: 9.332621544394415E157), there is no problem to use BigDecimal.doubleValue(). But you shouldn’t just do Math.pow(double, double) because if the result is bigger than MAX_VALUE you will just … Read more