search for: expr2

Displaying 20 results from an estimated 67 matches for "expr2".

Did you mean: expr
2006 Oct 27
2
all.names() and all.vars(): sorting order of functions' return vector
...culiar (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" "*" "x2" > all.vars(expr1) [1] "x1" "x2" > expr2 <- expression(x3 <- 0.5 * x1 - 0.7 * x2) > all.names(expr2) [1] "<-" "x3" "-" "*" "x1" "*" "x2" > all.vars(expr2) [1] "x3" "x1" "x2" > expr3 <- expression(x3 ~ 0.5 * x1 - 0....
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 like this one: "Erreur dans parse(file, n = -1, NULL, "?") : erreur de syntaxe ? la ligne 4: } 5: else&quo...
2007 May 26
1
bug from nlm function (PR#9711)
...o "b" est? ausente, sin default 1.Construction to objectiv functin with n=1 data >fllwform<-formula(~log(a)-log(b)-(a-1)*(log(x)-log(b))- (x^a)/(b^a)) > fllwfuncH <-deriv(fllwform,c("a","b"),function(a,b,x){}) > fllwfuncH function (a, b, x) { .expr2 <- log(b) .expr4 <- a - 1 .expr5 <- log(x) .expr6 <- .expr5 - .expr2 .expr9 <- x^a .expr10 <- b^a .expr19 <- .expr10^2 .expr23 <- 1/b .value <- log(a) - .expr2 - .expr4 * .expr6 - .expr9/.expr10 .grad <- array(0, c(length(.v...
2013 Feb 04
2
Modifying a function programmatically
...function ff <- function(a,b=2,c=4){a+b+c} # which I programmatically want to modify to a more specialized function in which a is replaced by 1 ff1 <- function(b=2,c=4){1+b+c} # I do as follows: vals <- list(a=1) (expr1 <- as.expression(body(ff))) expression({ a + b + c }) (expr2 <- do.call("substitute", list(expr1[[1]], vals))) { 1 + b + c } # This "works", eval(expr2, list(b=10,c=12)) [1] 23 # - but I would like a function. Hence I do: ll <- alist(b=, c=, eval(expr2)) ff2 <- as.function(ll) ff2(b=10,c=12) [1] 23 # BUT I am o...
2002 Aug 10
0
?subexpressions, D, deriv
...- exp(-0.5 * (((x - mu)/sigma)^2)) * (0.5 * (2 * (1/sigma * ((x - mu)/sigma)))) * (0.5 * (2 * (1/sigma * ((x - mu)/sigma))))) So I tried, in the interests of simplification.. > expr1<-expression( ((x-mu)/sigma)^2) > expr1 expression(((x - mu)/sigma)^2) > x [1] 5 15 20 > expr2<-expression(exp(-0.5*expr1)) > expr2 expression(exp(-0.5 * expr1)) > eval(expr2) Error in -0.5 * expr1 : non-numeric argument to binary operator I thought this might mean that I needed to define expr2 as calling expr1(x) , as follows > expr2<-expression(exp(-0.5*expr1(x))) > exp...
2004 May 14
2
NLME model question
...s , and i wanted to say that there are significant differences between the curves in two parameters that describe the pattern of growth. these parameters are from a logistic (r & k) . i have attempted to construct a self starting routine for nlme ie: SSGrowth_function(x, r, k) { .expr2 <- (k - 100000)/100000 .expr5 <- exp(((r * -1) * x)) .expr7 <- 1 + (.expr2 * .expr5) .expr13 <- .expr7^2 .value <- k/.expr7 .actualArgs <- match.call()[c("r", "k")] if(all(unlist(lapply(as.list(.actualArgs),...
2008 Oct 03
2
computing on expressions
Dear R-users, Suppose I have an expression: expr = expression(a>0) and now I want to modify it to expression(a>0 & b>0). The following doesn't work: expr = expression(expr & b>0) What would be a good way of doing this? Thanks, Vadim ________________________________ Note: This email is for the confidential use of the named addressee(s) only and may contain
2003 Jan 31
2
Varying texts in expression(paste())
Hi, I am using R a lot to make plots relating to radioactivity, I am often using expression() to label the plots with nuclide names written with superscripts, e.g. expression(paste("Releases of ", { }^{99},Tc," (TBq/year)"))->ywtext But, is there any simple way to change the number and name of the nuclide through a variable? I tried nuccode=expression({ }^{99},Tc)
2001 May 28
0
bugs in deriv(*, *, function.arg = ) (PR#953)
...ject: 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) { .expr1 <- cos(x) .expr2 <- .expr1 * y .expr4 <- cos(.expr2) .value <- sin(.expr2) .grad <- array(0, c(length(.value), 2), list(NULL, c("x", "y"))) .grad[, "x"] <- -.expr4 * (sin(x) * y) .grad[, "y"] <- .expr4 * .expr1 attr(.value, "gr...
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
2014 May 01
3
How to test if an object/argument is "parse tree" - without evaluating it?
...'m looking for a isParseTree() function such that I can call: expr0 <- foo({ x <- 1 }) expr1 <- foo(expr0) stopifnot(identical(expr1, expr0)) where foo() is: foo <- function(expr) { if (!isParseTree(expr)) expr <- substitute(expr) expr } I also want to be able to do: expr2 <- foo(foo(foo(foo(expr0)))) stopifnot(identical(expr2, expr0)) and calling foo() from within other functions that may use the same "tricks". The alternative is of course to do: foo <- function(expr, substitute=TRUE) { if (substitute) expr <- substitute(expr) expr } but i...
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 a...
2011 Apr 14
1
if (cond) expr1 expr2 ??
hi , this can be done easily if (cond) expr ex:  > for (i in 1: 4)+ {+ if(i==2) print("a")+ if(i==2) print("b")+ } output : [1] "a"[1] "b" but i want this  if (cond) expr1 expr 2 i tried this :  > for (i in 1: 4)+ {+ if(i==2) (print("b") && print("a"))+ } output : [1] "b"Error in print("b") &&
2005 Jul 12
2
Puzzled at ifelse()
I have a situation where this is fine: > if (length(x)>15) { clever <- rr.ATM(x, maxtrim=7) } else { clever <- rr.ATM(x) } > clever $ATM [1] 1848.929 $sigma [1] 1.613415 $trim [1] 0 $lo [1] 1845.714 $hi [1] 1852.143 But this variant, using ifelse(), breaks: > clever <- ifelse(length(x)>15, rr.ATM(x, maxtrim=7), rr.ATM(x))
2023 Jan 09
5
return value of {....}
...{, the result of the last expression evaluated. This has the visibility of the last evaluation. But both x AND y are created, but the "return value" is y. How can this be advantageous for solving practical problems? Specifically, consider the following code: F <- function(X) { expr; expr2; { expr5; expr7}; expr8;expr10} Both expr5 and expr7 are created, and are accessible by the code outside of the nested braces right? But the "return value" of the nested braces is expr7. So doesn't this mean that only expr7 should be accessible? Please help me entangle this (of cours...
2004 Jul 12
8
Gogoif with variables acting funny?
Using an example provided by "The Hitchhiker's Guide to Asterisk", I made the following addition to my extensions.conf file: [inbound-analog] exten => s,1,Wait(1) exten => s,2,SetVar(counter=0) exten => s,3,Answer() exten => s,4,Wait(1) exten => s,5,DigitTimeout(15) exten => s,6,ResponseTimeout(10)
2002 Aug 07
2
Constructing titles from list of expressions
Hello! I have the following problem: I have a function to construct three surfaceplots with a marker for an optimum, each of the plots has as title paste("Estimated ",pred.var.lab," for ",var.lab[1]," vs. ",var.lab[2],sep="") with different var.lab[1,2] each time. My problem is now that I need to allow for plotmath expressions in the variables pred.var.lab
2012 Jan 03
1
higher derivatives using deriv
Dear everyone, the following is obviously used to compute the nth derivative, which seems to work (deriv(sqrt(1 - x^2),x,n)) However, before using this, I wanted to make sure it does what I think it does but can't figure it out when reading the ?deriv info or any other documentation on deriv for that matter: deriv(expr, namevec, function.arg = NULL, tag = ".expr", hessian = FALSE,
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 bounds. Real example here...
2011 Aug 28
1
read.table: deciding automatically between two colClasses values
...hich reads the file nevertheless, and I also don't know the number of lines in the file. Perhaps one could catch an error, when the first invocation of read.table fails, and try the second one. However tryCatch doesn't seem to make it simple to write something like E = try(expr1 otherwise expr2) (if expr1 fails, evaluate expr2 instead) ? Oliver