Displaying 20 results from an estimated 30000 matches similar to: "How to read in expressions as function parameters?"
2004 Sep 24
2
Throwing expressions around
I'm trying to write some code that throws a few expressions around the
place, and I've boiled down the problem to be equivalent to this.
Consider the curve function which plots expressions in 'x':
> curve(x^2)
Now wrap that in the most naive wrapper function:
> fc=function(m){curve(m)}
and try it:
> fc(x^2)
Error in eval(expr, envir, enclos) : Object
2007 Mar 19
1
Forms lost focus in KDE
Hello,
I'm testing a simple delphi application that have 3 forms.
>From FORM1 (the main form) I press a button to show FORM2, then from
FORM2 I press a button to show FORM3, when I close FORM3, FORM1 becomes
focused instead of FORM2.
Every time you close a form or a dialog the application main form
becomes the active one.
This only happend in KDE, allowing windows manager to control the
2011 Jun 21
1
Setting up list of many equations for systemfit
Dear List Members,I am trying to set up a large system of equations and I am trying to find a simple way to set up the list command under the package system fit. Here is the example from system fit and what I am trying to do:
EQ1 <- Y1 ~ X1 + X2 + X4EQ2 <- Y2 ~ X2 + X3EQ3 <- Y3 ~ X2 + X3 + X4EQ4 <- Y4 ~ X1 + X3 + X4eqSystem <-list(form1 = EQ1, form2 = EQ2, form3 = EQ3, form4 = EQ4)
2012 Apr 01
1
indexing in a function doesn't work?
Hello,
I've written a small function that's supposed to save me some time, and
it's ending up killing it- the intention is to iteratively subset a dataset
fram on framevec, fit a model (either lm or nls depending on type) and
return the r2 or AIC from the model, respectively. Although as far as I can
tell in my code the plots are dependent on the fit of the model to the data
and the
2013 Feb 26
1
problem with nested loops
Each of the data sets contains monthly observations on price indices for 7 countries. I use the fitted values from reg1 in the reg2 model. The interior loop executes without error as long as I explicitly specify the data set, i.e. data=dat70. However the code fails to execute if I specify the model in the form of the commented line, i. e reg1 <-dynlm(form1,data=Dnames[j])
I get the following
2011 Nov 15
2
Regular expressions in R
Good afternoon list,
I have the following character strings; one with spaces between the maths
operators and variable names, and one without said spaces.
form<-c('~ Sentence + LEGAL + Intro + Intro / Intro1 + Intro * LEGAL +
benefit + benefit / benefit1 + product + action * mean + CTA + help + mean
* product')
2008 Apr 23
1
pdf() and histogram() in function call
Here is a function I wrote. It runs no problem, but generate empty pdf
files.
I can't find what is the problem.
create.pdf<- function(x, dir)
{
dir.create(dir, showWarnings = FALSE)
plist<- c("a", "b" , "c", "d")
for(j in plist)
{
filedir<- paste(dir, "/", j, ".pdf",
2010 Oct 12
1
R optimization and curve()?
I'm trying to figure out how to plot basic utility maximization results with
R, Ideally I'd like to plot the value of u through x1,x2 space, so you can
graph income / substitution effects easily...
also, it'd be nice if I could put a linear budget constraint on the graph
here's an example with cobb douglas utility
u <- function(x) {
x1 <- x[1]
x2 <- x[2]
2018 Dec 19
1
How to configure Dovecot to disable NIST's curves and still rertain EECDH?
My opinion is that security by RFC is not security, it's mommy medicine.
Standards have had a terrible time keeping up with security realities.
NITS's curves leak side channel information all over the place. I don't
have details on what implementations are set to calculate the NIST
curves in constant time, and that's not an easy feat to do anyway so I
don't want to depend
2003 Aug 14
2
Using spline parameters to generate data
# I need to generate some data. I'm modeling some time series that follow
a
# negative exponential decay (mostly). I have 20 samples that can easily
be fit with cubic splines.
# What I want to do is generate many thousands of similar samples using
the parameters from the splines
# For instance one data sample looks not unlike this:
foo.curve <- 1 * exp(-0.01 * 1:500) + 0.5
2011 Jun 28
1
plotting survival curves with model parameters
Hello.
I am trying to write an R function to plot the survival function (and
associated hazard and density) for a Siler competing hazards model.
This model is similar to the Gompertz-Makeham, with the addition of a
juvenile component that includes two parameters---one that describes
the initial infant mortality rate, and a negative exponential that
describes typical mortality decline over the
2009 Apr 21
1
How to compare parameters of non linear fitting curves
Hi,
I'm using a non linear model to fit experimental survival curves.
This model describes the fraction of "still active" experiments as a
function of time t as follows:
f(t)=(1+exp(-etaD*cD)) / (1+exp(etaD(t-cD)))
Moreover, when experiments are still active, they may change of state
(from 0 to 1). But they may fall inactive before changing their state
(their state still
2012 May 26
1
Plotting interactions from lme with ggplot
I'm fitting a lme growth curve model with two predictors and their
interaction as predictors. The multilevel model is nested so that level 1 is
time within the individual, and level 2 is the individual. I would like to
plot the mean group-level trajectories at plus and minus 1 SD from the mean
of the main effects composing the interaction term. Thus, the plot should
have 4 lines (mean
2009 Oct 28
1
need help explain the routine input parameters for seROC and cROC found in the R archive
Please help.
I found the code in the archive.
The author of this script says: "The first function (seROC) calculate
the standard error of ROC curve, the second function (cROC) compare
ROC curves."
Can some one explain to me what are the na, nn and r parameters which
are used as the input to the following two functions?
Thanks much in advance.
> From: Bernardo Rangel Tura
>
2008 Aug 12
1
[LLVMdev] A case where llvm created different cfg for same code
Hi,
The following two segments of code are actually the same,
but llvm created different cfg for them.
Form1:
1 #define N 10
2 int test(int A[N][N])
3 {
4 int i, j;
5 int result =0;
6 for(j=0; j+2<N; ++j) {
7 //for(i=0; i<j && i+j+1<N; i++) {
8 for(i=0; i<j && i<N-j-1; i++) {
9 A[i+j+1][j] = A[j + 2][j-i] + i;
10 }
11 }
12
13 for (i=0; i<N-2; ++i)
14 for (j=0;
2010 Sep 13
2
Overlay of two graphs of different axes
Though I have read quite a bit, and tried quite a bit, I have yet to
find a nice way to overlay 2 or more curves in the same plot, with
different ranges.
Here is simplified sample code to demonstrate the question:
> plot(2*(seq(1,5)), type="l", axes=FALSE)
> curve(2*(seq(1,5)), type="b", add=TRUE)
Error in curve(2 * (seq(1, 5)), type = "b", add = TRUE) :
2006 Jun 15
1
Repost: Estimation when interaction is present: How do I get get the parameters from nlme?
Gday,
This is a repost since I only had one direct reply and I remain
mystified- This
may be stupidity on my part but it may not be so simple.
In brief, my problem is I'm not sure how to extract parameter
values/effect sizes from a nonlinear
regression model with a significant interaction term.
My data sets are dose response curves (force and dose) for muscle that
also have two
2018 May 03
0
Calling the curve function with a character object converted into an expression
Sebastian:
This is somewhat arcane, perhaps even a bug (correction on this
welcomed). The problem is that the "expr" argument to curve() must be
an actual expression, not a call to parse that evaluates to an
expression. If you look at the code of curve() you'll see why
(substitute() does not evaluate expr in the code). Another simple
workaround other than sticking in the eval()
2007 Apr 05
1
Plotting multiple curves with lattice graphs
Hi List,
I would like to plot multiple curves (parametric
density curves) in one plot.
For example:
# parameters for three normal density curves
parms =
data.frame(ID=c(1,2,3),mu=c(50,55,60),sigma=c(10,12,15))
# I can easily draw three normal density curves using
curve():
curve(dnorm(x,mean=parms$mu[1],sd=parms$sigma[1]),from=0,
to=150, ylab="density", col="red")
2018 May 03
1
Calling the curve function with a character object converted into an expression
Typo: should be NULL not NUL of course
An alternative approach closer to your original attempt is to use
do.call() to explicitly evaluate the expr argument:
w <- "1 + x^2"
do.call(curve, list(expr = parse(text = w), ylab ="y"))
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus