Displaying 20 results from an estimated 50 matches for "expr1".
Did you mean:
expr
2003 May 09
2
Data-mining using R
...to some
criteria. In order to do that, what I want to be able to do, is selectively
filter the rows, graph some convinient variables, do some further filtering
and so on.
Let me take a more concrete example to make myself clear. Let's say
that I load a given dataset on a dataframe, namely expr1. This dataframe would
have the fields expr1$name, expr1$expression, expr1$reliablity, expr1$x,
expr1$y and so on, containing, for instance, 26000 rows. Now from these 26000 I'd
like to select only those ones satisfying expr1$expression > 2000,
expr1$reliability = 100 and plot a graph on expr...
2018 Jan 04
3
silent recycling in logical indexing
...ilently* recycled, even
>> when they are incommensurate lengths, when doing logical indexing?
>
> It is convenient to use a single `TRUE' in programmatic manipulation of subscripts in the same manner as using an empty subscript interactively:
>
>> mat<-diag(1:3)
>> expr1 <- quote(mat[])
>> expr1[[3]] <- TRUE
>> expr1[[4]] <- 2
>> eval(expr1)
> [1] 0 2 0
>> mat[,2]
> [1] 0 2 0
>
> HTH,
>
> Chuck
2004 May 14
1
covariates in lm
...237.7830 0.4114
Total 591 282.5871
If I do with R, I have been trying everything it occurrs to me and looked
everywhere and I could not obtain the same results and nothing is clear to
me... (I am so sorry... probably it is lack of statistical knowledge):
If I do:
> anova(lm(Expr1~depth*sector))
Analysis of Variance Table
Response: Expr1
Df Sum Sq Mean Sq F value Pr(>F)
depth 1 38.2 38.2 92.76 <2e-16 ***
sector 6 5.1 0.9 2.07 0.055 .
depth:sector 6 1.5 0.3 0.62 0.712
Residuals 578 237.8 0....
2002 Aug 10
0
?subexpressions, D, deriv
...gt; fx2
-(invroot2pi/sigma) * (exp(-0.5 * (((x - mu)/sigma)^2)) * (0.5 *
(2 * (1/sigma * (1/sigma)))) - 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 need...
2001 Oct 05
1
nls() fit to a lorentzian - can I specify partials?
...partial derivatives of my expression? (I suspect
it's doing derivatives numerically)
Can I specify the partials in advance?
I noticed the 'deriv' function, but am baffled by its output:
> deriv(~ a0 / (Q*sqrt((1-(x/f0)^2)^2 + ((x/f0) * 1/Q)^2)),"a0")
expression({
.expr1 <- x/f0
.expr10 <- Q * sqrt(1 - .expr1^2^2 + .expr1 * 1/Q^2)
.value <- a0/.expr10
.grad <- array(0, c(length(.value), 1), list(NULL, c("a0")))
.grad[, "a0"] <- 1/.expr10
attr(.value, "gradient") <- .grad
.value
})
I think .ex...
2007 Jul 30
2
deriv, loop
...ile="temp.txt")
print(prod(x))
file.remove("C:/R-2.5.0/temp.txt")
But how to convert the output of the loop to a vector that I can manipulate
(by prod or sum etc), without having to write and append to a file?
Question 2:
> deriv(~gamma(x),"x")
expression({
.expr1 <- gamma(x)
.value <- .expr1
.grad <- array(0, c(length(.value), 1), list(NULL, c("x")))
.grad[, "x"] <- .expr1 * psigamma(x)
attr(.value, "gradient") <- .grad
.value
})
BUT
> deriv3(~gamma(x),"x")
Error in deriv3.formu...
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" "*" "x2"
> all.vars(expr1)
[1] "x1" "x2"
> expr2 <- expression(x3 <- 0.5 * x1 - 0.7 * x2)
> all.names(expr2)
[1] "<-&quo...
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") && print("a") : invalid 'x' type in 'x && y'
but i expect the same out put as before ....
2006 Nov 18
1
deriv when one term is indexed
...onfint(). I thought that getting derivatives with deriv might
help but found that deriv does not automatically handle the
indexing of the beta parameter. I modified the output of deriv
from the case when the term beta is not indexed to give:
dd.deriv2 <- function (Blev, beta, gamm, GL)
{
.expr1 <- GL^gamm
.value <- Blev + rep(beta, each = 17) * .expr1
.grad <- array(0, c(length(.value), 5), list(NULL, c("Blev",
"beta.rouge", "beta.vert", "beta.bleu", "gamm" )))
.grad[, "Blev"] <- 1
.grad[1:17,...
2018 Jan 04
3
silent recycling in logical indexing
Sorry if this has been covered here somewhere in the past, but ...
Does anyone know why logical vectors are *silently* recycled, even
when they are incommensurate lengths, when doing logical indexing? This
is as documented:
For ?[?-indexing only: ?i?, ?j?, ?...? can be logical
vectors, indicating elements/slices to select. Such vectors
are recycled if necessary to match
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:...
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?
...valuated) 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() 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...
2005 Jun 03
2
Everyone-- the scoop on Bison/Flex --
Hey, everybody---
Ignorance CAN be bliss, at least for a while, but, .... Just so you
know...
A week or two ago, some upgrades to the expression parser (you know, the
expressions you put in $[ ... ] in your extensions.conf file) that I
submitted, have been merged into the CVS HEAD of the source.
Hopefully, for around 99.9% of you, it won't make any difference to you.
The Makefile has also
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)
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))
2009 May 10
4
Partial Derivatives in R
Quick question:
Which function do you use to calculate partial derivatives from a model
equation?
I've looked at deriv(), but think it gives derivatives, not partial
derivatives. Of course my equation isn't this simple, but as an example,
I'm looking for something that let's you control whether it's a partial or
not, such as:
somefunction(y~a+bx, with respect to x,
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)
2011 Aug 28
1
read.table: deciding automatically between two colClasses values
...the
last line, which 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
2013 Feb 04
2
Modifying a function programmatically
Dear list
# I have a 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(expr...