Re: [R] chaining closure arguments on-the-fly

2020-06-20 Thread Bert Gunter
OK -- you were referring explicitly to the function call. That's what I missed. Apologies for the noise. -- Bert On Sat, Jun 20, 2020 at 3:19 PM Benjamin Tyner wrote: > > On 6/20/20 5:49 PM, Bert Gunter wrote: > > Gents: > > (with trepidation) > > > > f(x = 3, y = g(expr)) > > **already** evalu

Re: [R] chaining closure arguments on-the-fly

2020-06-20 Thread Benjamin Tyner
On 6/20/20 5:49 PM, Bert Gunter wrote: Gents: (with trepidation) f(x = 3, y = g(expr)) **already** evaluates g in the environment of f, **not** in the environment of the caller. (This does not contradict Duncan's example -- 3 is a constant, not a variable). e.g. > f <- function(x = 3, y =

Re: [R] chaining closure arguments on-the-fly

2020-06-20 Thread Bert Gunter
Gents: (with trepidation) f(x = 3, y = g(expr)) **already** evaluates g in the environment of f, **not** in the environment of the caller. (This does not contradict Duncan's example -- 3 is a constant, not a variable). e.g. > f <- function(x = 3, y = x^2 +k){ + k <- 3 + x + y + } Ergo >

Re: [R] How to loop over two files ...

2020-06-20 Thread Rasmus Liland
On 2020-06-20 07:29 -0700, Bert Gunter wrote: > On Fri, Jun 19, 2020 at 11:17 PM Rasmus Liland wrote: > > On 2020-06-19 18:33 -0700, Bert Gunter wrote: > > > Why aren't you posting on the > > > Bioconductor Help forum instead > > > > Perhaps r-sig-genetics@ or r-sig-phylo@? > > genetics is not

[R] Running SEM

2020-06-20 Thread shahram salehi zadeh via R-help
I have a problem running SEM using lavaan. I have 44 items on likert scale. I would like to develop a model containing two latent factors. This is the model I have constructed: library(lavaan) library(sem) library(haven) getwd() View(Dissertation) kashk <- c(Dissertation$Q1, Dissertation$Q2, Diss

[R] Error in "plot(aov.object)" after upgradation to R-4.0.0 and R-4.0.1 for given R-Script-Example

2020-06-20 Thread Akhilesh Singh
Dear learned experts of R, I was writing a book through RStudio-Rmarkdown and had finally compiled it successfully based on R package R-3.6.2. Afterwards, I updated my R-3.6.2 to R-4.0.0 and even later to R-4.0.1. Then, the publishers demanded to recompile the book with font embedding, so I tried

Re: [R] chaining closure arguments on-the-fly

2020-06-20 Thread Duncan Murdoch
On 20/06/2020 4:44 p.m., Benjamin Tyner wrote: On 6/20/20 9:00 AM, Duncan Murdoch wrote: How about g <- function(x, y = x) {   f(x, y) } g(x = 3) or even yEqualsX <- function(f) function(x, y = x) f(x, y) yEqualsX(f)(x = 3) These are a lot like currying, but aren't currying, so they may be

Re: [R] chaining closure arguments on-the-fly

2020-06-20 Thread Benjamin Tyner
On 6/20/20 9:00 AM, Duncan Murdoch wrote: How about g <- function(x, y = x) {   f(x, y) } g(x = 3) or even yEqualsX <- function(f) function(x, y = x) f(x, y) yEqualsX(f)(x = 3) These are a lot like currying, but aren't currying, so they may be acceptable to you.  Personally I'd choose the f

Re: [R] How to loop over two files ...

2020-06-20 Thread Bert Gunter
genetics is not genomics. Nor are phylogenies. I still believe Bioc is the right resource. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Jun 19, 2020 at

Re: [R] chaining closure arguments on-the-fly

2020-06-20 Thread Duncan Murdoch
On 20/06/2020 7:15 a.m., Benjamin Tyner wrote: Greetings, Occasionally, I desire to call a function with one argument set to equal to another. Here is a toy example:    f <- function(x, y) {        x + y    }    f(x = 3, y = x) # Error in f(x = 3, y = x) : object 'x' not found So far

Re: [R] chaining closure arguments on-the-fly

2020-06-20 Thread Marc Schwartz via R-help
Hi Ben, How about something like this: f <- function(x, y = NULL) { if (is.null(y)) y <- x x + y } > f(3, 4) [1] 7 > f(3) [1] 6 Regards, Marc Schwartz > On Jun 20, 2020, at 7:15 AM, Benjamin Tyner wrote: > > Greetings, > > Occasionally, I desire to call a function with one arg

[R] chaining closure arguments on-the-fly

2020-06-20 Thread Benjamin Tyner
Greetings, Occasionally, I desire to call a function with one argument set to equal to another. Here is a toy example:    f <- function(x, y) {        x + y    }    f(x = 3, y = x) # Error in f(x = 3, y = x) : object 'x' not found So far, the most concise way I found to accomplish this is:

Re: [R] How to loop over two files ...

2020-06-20 Thread Ivan Krylov
On Fri, 19 Jun 2020 19:36:41 -0500 Ana Marija wrote: > Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), > "\n"), : argument 1 (type 'list') cannot be handled by 'cat' It might be a good idea to try to solve problems like this yourself instead of waiting for hours for someone to

Re: [R] Adjusting axis limits in ggplot2.

2020-06-20 Thread Rolf Turner
On 20/06/20 3:57 pm, Jeff Newmiller wrote: ?scale_x_discrete, in particular the expand argument. Thanks Jeff. Took me a while to get my head around it (I'm slow!!!) but I eventually got it. For the record, what I needed to do was set: ldCiPlot <- ldCiPlot + scale_x_discrete(expand=expan