similar to: Modifying a function programmatically

Displaying 20 results from an estimated 800 matches similar to: "Modifying a function programmatically"

2006 Oct 27
2
all.names() and all.vars(): sorting order of functions' return vector
Dear list-subscriber, in the process of writing a general code snippet to extract coefficients in an expression (in the example below: 0.5 and -0.7), I stumbled over the following peculiar (at least peculiar to me:-) ) sorting behaviour of the function all.names(): > expr1 <- expression(x3 = 0.5 * x1 - 0.7 * x2) > all.names(expr1) [1] "-" "*" "x1"
2008 Jun 20
3
FF3 printing problem on Centos 4.x
I'm using Centos 4.x (fully up to date) on a system at work. I have also been using firefox 2 (directly from mozilla.org) on it for a long time, and it tends to work just fine. yesterday I installed the new FF3 release. It works fine too, with one exception: The print dialog shows no printers! The print button is greyed out! There actually four or five printers defined on the system, and all
2012 May 22
2
Creating functions with a loop.
Hi I am trying to create n functions where each function is defined in function one step before, i.e. something like ff.k(x) = ff.j(x) - sum(1:j), for j=k-1 Is it possible? If it isn't and I manually create each function then is their a way to call them through a loop? My objective is to calculate something like result.k = ff.k(x1)/ff.k(x2) for k in 2:n Thank you for your time,
2006 Jul 18
2
I think this is a bug
Hello! I work with: R : Copyright 2006, The R Foundation for Statistical Computing Version 2.3.1 (2006-06-01) On Windows XP Professional (Version 2002) SP2 I think there is a bug in the conditional execution if (expr1) {expr2} else {expr3} If I try: "if (expr1) expr2 else expr3" it works well but when I put the expression expr2 and expr3 between {} I receive an error message
2023 Jan 11
1
return value of {....}
I am more than a little puzzled by your question. In the construct {expr1; expr2; expr3} all of the expressions expr1, expr2, and expr3 are evaluated, in that order. That's what curly braces are FOR. When you want some expressions evaluated in a specific order, that's why and when you use curly braces. If that's not what you want, don't use them. Complaining about it is like
2014 May 01
3
How to test if an object/argument is "parse tree" - without evaluating it?
This may have been asked before, but is there an elegant way to check whether an variable/argument passed to a function is a "parse tree" for an (unevaluated) expression or not, *without* evaluating it if not? Currently, I do various rather ad hoc eval()+substitute() tricks for this that most likely only work under certain circumstances. Ideally, I'm looking for a isParseTree()
2008 Mar 25
2
a JavaScript front-end for Babelmark
Hi, I've built a quick-and-dirty diff GUI for Babelmark (thanks, Michel!). You can get it as a bookmarklet here: http://attacklab.net/babelmark/ If either Michel or Tom is interested in hosting this, I'll be happy to do the grunt work for a real integration. It's kind of pain in the ass to hit the bookmarklet every time you get new data from the server. I've tested this
2011 Aug 28
1
read.table: deciding automatically between two colClasses values
Hello, I have a function for reading a data-frame from a file, which contains E = read.table(file = filename, header = T, colClasses = c(rep("integer",6),"numeric","integer",rep("numeric",8)), ...) Now a small variation arose, where colClasses =
2009 Dec 09
4
equivalent of ifelse
Hi, Is there any equivalent for ifelse (except if (cond) expr1 else expr2) which takes an atomic element as argument but returns vector since ifelse returns an object of the same length as its argument? x = c(1,2,3) y = c(4,5,6,7) z = 3 ifelse(z <= 3,x,y) would return x and not 1 thanks
2002 Aug 10
0
?subexpressions, D, deriv
Hi all, I am not used to using the computer to do calculus and have up to now done my differentiation "by hand" , calling on skills I learned many years ago and some standard cheat sheets. My interest at present is in getting the second derivative of a gaussian, which I did by hand and results in a somewhat messy result involving terms in sigma^5 .. I have done some spot checks
2014 Sep 19
2
[LLVMdev] poison and select
Today I ran into another aspect of the poison problem... Basically, SimplifyCFG wants to take expr1 && expr2 and flatten it into x = expr1 y = expr2 x&y This isn't safe when expr2 might execute UB. The consequence is that no LLVM shift instruction is safe to speculatively execute, nor is any nsw/nuw/exact variant, unless the operands can be proven to be in
2023 Jan 13
1
return value of {....}
R's { expr1; expr2; expr3} acts much like C's ( expr1, expr2, expr3) E.g., $ cat a.c #include <stdio.h> int main(int argc, char* argv[]) { double y = 10 ; double x = (printf("Starting... "), y = y + 100, y * 20); printf("Done: x=%g, y=%g\n", x, y); return 0; } $ gcc -Wall a.c $ ./a.out Starting... Done: x=2200, y=110 I don't like that
2001 May 28
0
bugs in deriv(*, *, function.arg = ) (PR#953)
Also, this should have gone in R-bugs quite a while ago : ------- start of forwarded message ------- From: Martin Maechler <maechler@stat.math.ethz.ch> To: R-core@stat.math.ethz.ch Subject: PROTECT() bugs in deriv(*, *, function.arg = ) Date: Mon, 16 Apr 2001 21:02:10 +0200 In R versions 0.50 and 0.64.2 , the following worked > deriv(expression(sin(cos(x) * y)),
2008 Mar 25
6
Prototype 1.6.0.2 + Firefox 3 Enumerable problems
I am using Prototype 1.6.0.2 on Firefox 3.0b4. The following does not work when I enter it in Firebug: $A([1,2,3,4]).each(function(n) {alert(n);}); The above is just an example. Any array, using $A and any enumerable method, returns the following: TypeError: iterator.bind is not a function Seems like some objects are not being extended correctly? Using Prototype 1.5.0 on Firefox 3.0b4, this
2009 Mar 23
4
newton method
Hi R-users, Does R has a topic on newton's method? Thank you for the info.
2012 Aug 07
4
Execution of a function
Hi >i have aproblem withe execution of my function >first, i wrote my function in the script of R >nom_fonction <- function(arg1[=expr1], arg2[=expr2], ...){ bloc d'instructions } > when i want to have the result i mean the laste instruction in the bloc of > instruction , i try to >wrote the name of function >source(aj.fun) Error in readLines(file, warn =
2001 May 28
1
deriv (PR#953)
------- start of forwarded message ------- From: Martin Maechler <maechler@stat.math.ethz.ch> To: R-core@stat.math.ethz.ch Subject: PROTECT() bugs in deriv(*, *, function.arg = ) Date: Mon, 16 Apr 2001 21:02:10 +0200 In R versions 0.50 and 0.64.2 , the following worked > deriv(expression(sin(cos(x) * y)), c("x","y"), function(x,y){}) function (x, y)
2001 May 30
2
environments
I would like to be able, inside a function, to create a new function, and use it as part of a formula as an argument to, say, gnls or nlme. for example: MyTop <- function(data=dta) { Cexp <- function(dose,A,B,m){...} Model <- as.formula(paste("y","~ Cexp(",paste(formals(Cexp),collapse =", "),")")) MyCall <-
2001 May 01
0
SSfpl self-start sometimes fails... workaround proposed
Hello, nls library provides 6 self-starting models, among them: SSfp, a four parameters logistic function. Its self-starting procedure involves several steps. One of these steps is: pars <- as.vector(coef(nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal)))), data = xydata, start = list(lscal = 0), algorithm = "plinear"))) which assumes an initial value of lscal equal to 0. If lscal
2003 Sep 04
1
Regular expression matching for ":" - examples needed
It is again perhaps my recent spate of bad sleeping that has prevented my brain from wrapping around this explanation, or it is perhaps my inherent hatred of regular expression syntax. However, I have been unable to put this into a working form after staring at it for a while and trying different recipes. If anyone wants to take a stab at this, I'd appreciate it. (from