similar to: Creating model formulas programmatically

Displaying 20 results from an estimated 8000 matches similar to: "Creating model formulas programmatically"

2025 Mar 30
1
Creating model formulas programmatically
Another solution. reformulate + substitute + as.formula: substitute(~ (.)^2, list(. = reformulate(somenames)[[2]])) |> as.formula() On Sat, Mar 29, 2025 at 5:31?PM Bert Gunter <bgunter.4567 at gmail.com> wrote: > > Note: I am almost certain that this has been asked and answered here > before, so my apologies for the redundant query. > > I also know that there are several
2025 Mar 30
1
Creating model formulas programmatically
Gabor, Duncan, et. al. 1. Thank you for your great comments and solutions. This is what I was hoping for! 2. Duncan: I completely agree with your criticisms. In fact, I realized the for() loop only needed the <- assignment, but your comment is important to note. However, I didn't like the for() loop either; I *much* preferred your Reduce() solution which is exactly the sort of elegant
2025 Mar 30
1
[External] Creating model formulas programmatically
As always, I would like to thank all who responded for their insights and suggestions. I have learned from them. Thus far, my own aesthetic preference -- and therefore not to be considered in any sense as a "best" approach -- is to use Duncan's suggestion to produce the call directly with call() rather than substitute in my simple for() loop; i.e. somenames <-
2025 Mar 30
1
[External] Creating model formulas programmatically
I am confused. Richard's answer that Bert did not like did not use parse explicitly. Richard pasted together a string that a function like lm() will have to parse to run the analysis. However, the answers so far do not use parse(). In the reply to Richard, Bert indicated we cannot use strings. Even if I pass a vector where R can assume that the first variable is the dependent variable and all
2025 Mar 29
1
[External] Creating model formulas programmatically
The general formula is y ~ a + b + c + ... There is this approach: formula <- reformulate(independent_vars, response = "y") model <- lm(formula, data = mydata) summary(model) It does not generate a string object, but the formula is still a string even if it is of class formula. Also, in this approach you only get + and if you want interactions or such you will need to code them
2025 Mar 30
1
[External] Creating model formulas programmatically
Hello, I thought of answering "reformulate can solve the problem" but how do you create quadratic terms with reformulate? ~(Heigh + Ho + Silver + Away)^2 is still a problem with no solution that I know of but paste/as.formula. Or Bert's bquote or substitute. Rui Barradas ?s 23:18 de 29/03/2025, Ebert,Timothy Aaron escreveu: > The general formula is y ~ a + b + c + ... >
2025 Mar 29
2
[External] Creating model formulas programmatically
Thanks, Rich. I thought of that, too, but it violates the spirit of my restraints (to avoid character strings), which I unfortunately did not clearly articulate. So my apologies for that failure. My concern is that with more complex model formula, using as.formula, etc. to parse/convert character strings can get a bit hairy. But in most cases, as here maybe, it may be perfectly fine. So think of
2025 Mar 29
1
[External] Creating model formulas programmatically
> somenames <- c("Heigh", "Ho", "Silver", "Away") > as.formula(paste("~(",paste(somenames, collapse="+"),")^2")) ~(Heigh + Ho + Silver + Away)^2 > > On Mar 29, 2025, at 14:30, Bert Gunter <bgunter.4567 at gmail.com> wrote: > > somenames <- c("Heigh", "Ho", "Silver",
2025 Mar 30
1
[External] Creating model formulas programmatically
my take of the assignment was to avoid 'parse' specifically. we start with a character vector, so avoiding characters is not possible. i was dealing with the fortune "if parse is the answer, you have the wrong question" Sent from my iPhone On Mar 29, 2025, at 15:39, Bert Gunter <bgunter.4567 at gmail.com> wrote: ? Thanks, Rich. I thought of that, too, but it violates
2008 Jan 17
2
"non-plot" plotting
I really do not know ho to else title this ... I want to draw something like the attached png with R and would like to poll you on how to start ... make an empty plot first and then start positioning the characterstring by 'text' and then drawing the lines ... Joh -------------- next part -------------- A non-text attachment was scrubbed... Name: sequence.png Type: image/png Size: 7117
2017 Jun 29
2
Changing ggplot2 legend key/title to custom text
Hi all, ok I have this issue: I want to change my graphs legends to custom text, often requiring the use of superscripts/subscripts I tried to use this instruction I found on stack overflow: labs(x = "R(Ohm)", y= "CDF", aesthetic= " Content (%)" ) but it wont' seem to work. Also tried bquote for super/ subscripts xlab(bquote(~x~/(~x~ + ~MO[2]~)*
2019 Apr 18
1
Bug in the "reformulate" function in stats package
So here is it as txt file. It is funny that a R file is restricted in R-devel mailing list. Anyhow, in this case R-core have a few choices here: * ignore my solution * show that it is actually bad or worse * consider adding it Considering, that it is a minor change from previous version and doesn't bother the existing usage, I saw the necessity to submit it here. But newer solution
2007 Nov 21
1
fitting a line to a logaritmic plot
Hi, I have processed measurements of a rough surface to a heigh-height correlation plot. What the meaning of this exactly is, is not important. Only that it is a plot that had two (almost ) linear parts when plotted on a logaritmic scale. In this plot, I want to draw the best fitting lines for these linear parts but I just can't get it done. It is easy when the scales are linear but as you
2008 Dec 12
1
How to mimic select.list using RGtk2/gWidgetsRGtk2?
I want to write a function mimic the function of select.list(), here is my preliminary version. select <- function(x,multiple=TRUE,...){ ans<-new.env() g <- gwindow(title=title,wid=200,heigh=500) x1<-ggroup(FALSE,con=g) x2<-gtable(x,multiple=multiple,con=x1,expand=TRUE) gbutton("OK",con=x1,handler=function(h,...){ value <- svalue(x2) if (length(value)==0)
2010 Nov 08
2
Several lattice plots on one page
Dear all, I am trying (!!!) to generate pdfs that have 8 plots on one page: df = data.frame( day = c(1,2,3,4), var1 = c(1,2,3,4), var2 = c(100,200,300,4000), var3 = c(10,20,300,40000), var4 = c(100000,20000,30000,4000), var5 = c(10,20,30,40), var6 = c(0.001,0.002,0.003,0.004), var7 = c(123,223,123,412), var8 = c(213,123,234,435), all = as.factor(c(1,1,1,1)))
2017 Jun 29
0
Changing ggplot2 legend key/title to custom text
Hi There are plenty of examples https://stackoverflow.com/questions/6202667/how-to-use-subscripts-in-ggplot2-legends-r https://stackoverflow.com/questions/19507742/using-expressionpaste-to-insert-math-notation-into-a-ggplot-legend which you can modify. If you say "but it wont' seem to work" how can we know what does it mean? Plotmath expressions are rather tricky, especially if
2017 Jun 29
1
Changing ggplot2 legend key/title to custom text
Hi Petr and thanks for your reply, That's the problem I don't want to modify the labels of my legends but the title of the legend in itself inserting my custom text :) Take for example the 1st graph in this tutorial http://www.sthda.com/english/wiki/ggpubr-r-package-ggplot2-based-publication-ready-plots I want to change the "sex" in "sex subscript 2" or "
2010 Jul 18
5
package "plotrix"
I installed package plotrix because reading its vignette it looks like it can help me solve a "legend" problem. The package instaleed correctly on my Mac OS/X 10.5.8 But I cannot reproduce the examples centered on function "lgendg". > library(plotrix) > plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1),type="n", + main="Test of grouped legend function") >
2015 Jan 26
2
Inspect a "delayed" assigned whose value throws an error?
On Mon, Jan 26, 2015 at 12:24 PM, Hadley Wickham <h.wickham at gmail.com> wrote: > If it was any other environment than the global, you could use substitute: > > e <- new.env() > delayedAssign("foo", stop("Hey!"), assign.env = e) > substitute(foo, e) > > delayedAssign("foo", stop("Hey!")) > substitute(foo) Hmm... interesting
2006 Dec 15
2
Bandwidth requirements for 1, 000, 000 minutes a month
This may expose my ignorance, but here goes :) I've been asked to figure out how much bandwidth would be needed to handle 1,000,000 minutes a month. Here's the environment: ) All calls are received via SIP. ) All calls use the ulaw codec. ) Calls average 10 minutes in duration. ) The "busiest" hour will account for 10% of the daily total. This is how I'm figuring