search for: formulas

Displaying 20 results from an estimated 7255 matches for "formulas".

Did you mean: formula
2000 Oct 12
2
works in R-1.1.1 but not in R-development; why?
Dear All, A library (PHYLOGR) that passed the usual tests in R-1.1.1 gives errors with R-devel; my (mis?)understanding of scoping rules is that it should have worked in both. The problems seem related to using the name of the data frame for extracting weights or subsets within a function call. The problems can be reproduced as follows: ********************** datai <- data.frame( y =
2006 Jun 13
2
levelplot and source() problems
I have been using levelplot but have had trouble calling it inside functions - something seems to go wrong when it's not called directly from the R command prompt. Simplest reproducible example: $ R --vanilla > library(lattice) > levelplot(matrix(1:4,2,2)) - This gives a nice plot in soothing pastel colors. Now, with a file lptest.r containing 2 lines: library(lattice)
2008 Dec 26
3
lm() with same formula but different column/factor combinations in data frame
Hi, I am trying to find an efficient way of applying a linear regression model to different factor combinations in a data frame. I want to obtain the output with minimal or no use of loops if possible. Please let me know if this query is unclear. Thanks, Murtaza
2011 Jul 13
1
question on formula and terms.formula()
I'm trying to create a formula object to pass on to a function that applies the function terms.formula() to it. f <- function(formula, ...) { ... mf <- match.call() term <- terms.formula(mf$formula) ... } However, my code below gives an error. form <- as.formula("y~x") f(form, ...) The error message was: Error in terms.formula(mf$formula): argument is not a valid
2008 May 30
2
scoping problem when calling lm(precomputed formula, weights) from function (PR#11540)
I've run into a scoping problem in R. I'm calling a function that * creates a formula * calculates a weight vector * calls lm with that formula and weights This fails. Here's a simplified reproduce example: # f works, g doesn't, h is a workaround rm(w) data <- data.frame(y=runif(20), x=runif(20), z=runif(20)) f <- function(k){ w <- data$z^k coef(lm(y~x, data
2017 Aug 23
3
boot.stepAIC fails with computed formula
Until I get a fix that works, a work-around would be to rename the 'y1' column, used a fixed formula, and rename it back afterwards. Thanks for your help. SGO. -----Original Message----- From: Bert Gunter [mailto:bgunter.4567 at gmail.com] Sent: 22 August 2017 20:38 To: Stephen O'hagan <SOhagan at manchester.ac.uk> Cc: r-help at r-project.org Subject: Re: [R] boot.stepAIC
2017 May 23
0
Allow dot in RHS of update.formula's old formula
Feature request: I want to use update.formula to subtract an intercept (or other) term from a formula with a dot on the RHS. However, as this causes an error, I propose a patch below. Thus, I want: > update.formula(y ~ ., ~ . -1) [1] y ~ . - 1 Instead I get this error: Error in terms.formula(tmp, simplify = TRUE) : '.' in formula and no 'data' argument While the error
2007 Oct 01
4
Disentagling formulas
I am writing a program in which I would like to take in a formula, change the response (Y) variable into something else, and then pass the formula, with the new Y variable to another function. That is, I am starting with formula <- Y~X1+X2+X3 and I'd like to do something like Y <- formula$Y newY <- f(Y) lm(newY~X1+X2+X3) So far, it seems that my
2013 May 17
2
How could I see the source code of functions in an R package?
...uot;pht") ht <- eval(ht, parent.frame()) return(ht) } if (!is.null(dots$instruments)) { as.Formula(formula, dots$instruments) deprec.instruments <- paste("the use of the instruments argument is deprecated,", "use two-part formulas instead") warning(deprec.instruments) } if (inherits(data, "pdata.frame") && !is.null(index)) warning("the index argument is ignored because data is a pdata.frame") if (!inherits(data, "pdata.frame")) data <- pdata.fr...
2017 Aug 23
0
boot.stepAIC fails with computed formula
It seems that if you build the formula as a character string, and postpone the "as.formula" into the lm call, it works. instead of frm1 <- as.formula(paste(trg,"~1")) use frm1a <- paste(trg,"~1") and then strt <- lm(as.formula(frm1a),dat) regards, Heinz Stephen O'hagan wrote/hat geschrieben on/am 23.08.2017 12:07: > Until I get a fix that works, a
2007 Jul 16
5
formula(CO2)
The formula attribute of the builtin CO2 dataset seems a bit strange: > formula(CO2) Plant ~ Type + Treatment + conc + uptake What is one supposed to do with that? Certainly its not suitable for input to lm and none of the examples in ?CO2 use the above.
2004 May 25
3
problems with plot.formula
With the recent changes in R 1.9.x, it is now impossible to properly call plot on a formula() where the formula is provided via a named first argument. On today's R-1.9.1-alpha: > x <- 1:10 > y <- rnorm(x,0.25) > > plot(x~y) > > plot(x=x~y) Error in terms.formula(formula, data = data) : argument is not a valid model > > plot(formula=x~y) Error in
2004 Jul 15
5
formula
Hi, i 'dont understand how to take a general formula, view this: x<-1:5 y<-c(0,1,1.7,2,2.1.4) dummy<-data.frame(x=x,y=y) formula<-"y~A*log(x)/log(2)" formu<-as.formula(formula) fm<-lm(formu,data=dummy) Error in eval(expr, envir, enclos) : Object "A" not found but A is the parameter of fitting, why is this?Thanks Ruben
2010 Jul 06
4
Assign Formulas to Arrays or Matrices?
Hi, I am very new to R. I am hoping to create formulas and assign them to locations within an array (or matrix, if it will work). Here's a simplified example of what I'm trying to do: form.arr <- array(31,5,3) for (i in seq(from=1, to=31, by=1)) { for (j in seq(from=1, to=5, by=1)) { form.arr[i,j,] <- as.formula(y~1+2) } } which re...
2011 Nov 24
2
proper work-flow with 'formula' objects and lm()
Dear all I have a work-flow issue with lm(). When I use > lm(y1~x1, anscombe) Call: lm(formula = y1 ~ x1, data = anscombe) Coefficients: (Intercept) x1 3.0001 0.5001 I get as expected the formula, "y1 ~ x1", in the print()ed results or summary(). However, if I pass through a formula object > (form <- formula(y1~x1)) y1 ~ x1 > lm(form, anscombe) Call:
2007 Jan 09
5
a question of substitute
Hi all, I want to write a wrapper for an analysis of variance and I face a curious problem. Here are two different wrappers: fun.1 <- function(formula) { summary(aov(formula)) } fun.2 <- function(formula) { oneway.test(formula) } values <- c(15, 8, 17, 7, 26, 12, 8, 11, 16, 9, 16, 24, 20, 19, 9, 17, 11, 8, 15, 6, 14) group <- rep(1:3, each=7) # While the first
2011 Jan 07
1
formula(model.frame(y~.^2, data=d)) does not return formula from terms attribute of the model.frame
In R 2.12.0 I get > d <- data.frame(x=1:10, y=log(1:10), f3=LETTERS[rep(1:3,c(3,3,4))]) > m <- model.frame(y~.^2, data=d) > formula(m) y ~ x + f3 In S+ formula(m) gives formula given to model.frame(), but in R you have to do the following get that formula: > formula(attr(m, "terms")) y ~ (x + f3)^2 Would it break anything to add to the top of
2009 Jul 30
3
update.formula and backticked colons
I just noticed the following in update.formula and I'm wondering if this behavior is the intention of the developers. Here's an example: update(`a: b` ~ x, ~ . + y) Note now that the response has no backticks and is interpreted as a:b (i.e. ":" is now an operator). This is because in update.formula the call to terms.formula uses simplify = TRUE. I'm working with data that
2019 Jun 14
1
Bug report: 'formula("x")' loops infinitely ('formula("y")' does not)
Dear,?? The script'formula("x")' loops infinitely. More specifically, it throws thefollowing error:? ? Error: evaluationnested too deeply: infinite recursion / options(expressions=)?? ? As a side effect,this makes an IDE like RStudio to crash. On the other hand,the script 'formula("y")'?works as expected : if ?y? does notexist in the global environment,
2003 Jun 18
3
update.default bugfix (PR#3288)
According to the man page for formula, "a formula object has an associated environment". However, update.default doesn't use this environment, which creates problems like the following: make.model <- function(x) { lm(medv~.,x) } library(MASS) data(Boston) fit = make.model(Boston) fit = update(fit,".~.-crim") # Object "x" not found Here is a