similar to: Multiple Assignment built into the R Interpreter?

Displaying 20 results from an estimated 8000 matches similar to: "Multiple Assignment built into the R Interpreter?"

2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
I think the standard way to do this in R is given by list2env(), as described in a couple of answers on the SO page you linked. The syntax you proposed would be likely to be confusing in complex expressions, e.g. f(A, C, Q, R = init_matrices(X, Y, Z)) would obviously not work but wouldn't trigger a syntax error, and f((A, C, Q, R = init_matrices(X, Y, Z))) could work, but looks
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
Thanks Duncan, I know about list2env(), in fact a previous version of collapse::`%=%` was coded as "%=%" <- function(lhs, rhs) { if(!is.character(lhs)) stop("lhs needs to be character") if(!is.list(rhs)) rhs <- as.vector(rhs, "list") if(length(lhs) != length(rhs)) stop("length(lhs) not equal to length(rhs)") list2env(`names<-`(rhs,
2023 Mar 12
2
Multiple Assignment built into the R Interpreter?
Thanks Gabriel and Kevin for your inputs, regarding your points Gabriel, I think Python and Julia do allow multiple sub-assignment, but in-line with my earlier suggestion in response to Duncan to make multiple assignment an environment-level operation (like collapse::%=% currently works), this would not be possible in R. Regarding the [a] <- coolest_function() syntax, yeah it would mean do
2023 Mar 11
2
Multiple Assignment built into the R Interpreter?
FWIW, it's possible to get fairly close to your proposed semantics using the existing metaprogramming facilities in R. I put together a prototype package here to demonstrate: https://github.com/kevinushey/dotty The package exports an object called `.`, with a special `[<-.dot` S3 method which enables destructuring assignments. This means you can write code like: .[nr, nc] <-
2023 Mar 12
1
Multiple Assignment built into the R Interpreter?
Kevins package is very nice as a proof of concept, no doubt about that, but it is not at the level of performance or convenience that a native R implementation would offer. I would probably not use it to translate matlab routines into R packages placed on CRAN, because it?s an additional dependency, I have a performance burden in every iteration, and utils::globalVariables() is everything but
2023 Mar 13
1
Multiple Assignment built into the R Interpreter?
Dear All, As a maintainer of large, complex packages, I can think of many places in which deconstructing assignment would simplify the code, as well as facilitate readability by breaking up larger functions into helpers, so I would be very glad to see this incorporated somehow. I think the crux of the matter is that while there is a number of ways to implement deconstructing assignment within R,
2023 Mar 13
1
Multiple Assignment built into the R Interpreter?
Yes, this is really a problem with the checks, not with the language. A simpler approach than your alternativeAssignment function would be simply to allow globalVariables() to be limited to a single function as the note in its help page says. This might be tedious to write by hand, but could be automated using methods like "dotify" in dotty. Duncan Murdoch On 12/03/2023 10:36
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
On 11/03/2023 4:42 p.m., Sebastian Martin Krantz wrote: > Thanks Duncan and Ivan for the careful thoughts. I'm not sure I can > follow all aspects you raised, but to give my limited take on a few: > >> your proposal violates a very basic property of the language, i.e. that all statements are expressions and have a value. > What's the value of 1 + (A, C =
2023 Mar 12
1
Multiple Assignment built into the R Interpreter?
On 12/03/2023 6:07 a.m., Sebastian Martin Krantz wrote: > Thinking more about this, and seeing Kevins examples at > https://github.com/kevinushey/dotty > <https://github.com/kevinushey/dotty>, I think this is the most R-like > way of doing it, > with an additional benefit as it would allow to introduce the useful > data.table semantics DT[, .(a = b, c, d)] to more
2023 Mar 11
3
Multiple Assignment built into the R Interpreter?
Thanks Duncan and Ivan for the careful thoughts. I'm not sure I can follow all aspects you raised, but to give my limited take on a few: > your proposal violates a very basic property of the language, i.e. that all statements are expressions and have a value. > What's the value of 1 + (A, C = init_matrices()). I'm not sure I see the point here. I evaluated 1 + (d =
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
There are some other considerations too (apologies if these were mentioned above and I missed them). Also below are initial thoughts, so apologies for any mistakes or oversights. For example, if [a, b] <- my2valuefun() works the same as local({ tmp <- my2valuefun() stopifnot(is.list(tmp) && length(tmp) == 2) a <<- tmp[[1]] b <<- tmp[[2]] }) Do we expect [a[1], b[3]]
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
On 11/03/2023 9:54 a.m., Sebastian Martin Krantz wrote: > Thanks Duncan, > > I know about list2env(), in fact a previous version of collapse::`%=%` > was coded as > > "%=%" <- function(lhs, rhs) { > ?? if(!is.character(lhs)) stop("lhs needs to be character") > ?? if(!is.list(rhs)) rhs <- as.vector(rhs, "list") > ?? if(length(lhs)
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
On 11/03/2023 11:57 a.m., Ivan Krylov wrote: > On Sat, 11 Mar 2023 11:11:06 -0500 > Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > >> That's clear, but your proposal violates a very basic property of the >> language, i.e. that all statements are expressions and have a value. > > How about reframing this feature request from multiple assignment >
2019 Feb 26
5
Improved Data Aggregation and Summary Statistics in R
Dear Developers, Having spent time developing and thinking about how data aggregation and summary statistics can be enhanced in R, I would like to present my ideas/efforts in the form of two commands: The first, which for now I called 'collap', is an upgrade of aggregate that accommodates and extends the functionality of aggregate in various respects, most importantly to work with
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
On Sat, 11 Mar 2023 11:11:06 -0500 Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > That's clear, but your proposal violates a very basic property of the > language, i.e. that all statements are expressions and have a value. How about reframing this feature request from multiple assignment (which does go contrary to "everything has only one value, even if it's
2012 Apr 26
2
How does .Fortran "dqrls" work?
Hi, all. I want to write some functions like glm() so i studied it. In glm.fit(), it calls a fortran subroutine named "dqrfit" to compute least squares solutions to the system x * b = y To learn how "dqrfit" works, I just follow how glm() calls "dqrfit" by my own example, my codes are given below: > qr <- >
2016 Oct 24
3
typo or stale info in qr man
man for `qr` says that the function uses LINPACK's DQRDC, while it in fact uses DQRDC2. ``` The QR decomposition of the matrix as computed by LINPACK or LAPACK. The components in the returned value correspond directly to the values returned by DQRDC/DGEQP3/ZGEQP3 ```
2003 Jul 16
2
Is there a bug in qr(..,LAPACK=T)
The following snippet suggests that there is either a bug in qr(,LAPACK=T), or some bug in my understanding. Note that the detected rank is correct (= 2) using the default LINPACK qr, but incorrect (=3) using LAPACK. This is running on Linux Redhat 9.0, using the lapack library that comes with the Redhat distribution. I'm running R 1.7.1 compiled from the source. If the bug is in my
2020 Oct 20
2
Is there a new way to search the listserv archives?
I see the link here <https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser>, but clicking it results in a 404. Before I waste everyone's time posting my question, I really wanted to search to see if it's been solved already. -------------- next part -------------- An HTML attachment was scrubbed... URL:
2009 Jun 17
3
Matrix inversion-different answers from LAPACK and LINPACK
Hello. I am trying to invert a matrix, and I am finding that I can get different answers depending on whether I set LAPACK true or false using "qr". I had understood that LAPACK is, in general more robust and faster than LINPACK, so I am confused as to why I am getting what seems to be invalid answers. The matrix is ostensibly the Hessian for a function I am optimizing. I want to get