Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Mutate a list, for instance using list.update #114

Open
gifi opened this issue Feb 27, 2016 · 3 comments
Open

[Feature request] Mutate a list, for instance using list.update #114

gifi opened this issue Feb 27, 2016 · 3 comments

Comments

@gifi
Copy link

gifi commented Feb 27, 2016

Hi @renkun-ken ,
Thank you for this very helpful package!
I was wondering if there is any plan to add mutating capabilities in rlist. For instance, shouldn't be possible to list.update in-place ? e.g.: after doing this

yyy <- list(foo = list(a = 0, b = 1))
list.update(yyy, a = a + 10)

have the following as the result:
print(yyy)

$foo
$foo$a
[1] 10

$foo$b
[1] 1
@renkun-ken
Copy link
Owner

Thanks, I'm trying to work out something like this. It looks best to use Rcpp to handle this.

@gifi
Copy link
Author

gifi commented Mar 2, 2016

Hi,
Thanks for considering the proposition. I did my homework and, it turned out major changes would be required to overhaul the current rlist code base with a Rcpp-backend. My best wishes go to you when you'll decide to take on the task.

@KarolDaniluk
Copy link

It would be great, to have such feature. For example:

my_list <- list(
  a = list(m = 1, n = 1, foo = list(i = 1, j = 1)),
  b = list(m = 2, n = 2, foo = list(i = 2, j = 2)),
  c = list(m = 3, n = 3, foo = list(i = 3, j = 3))
)

test1 <- list.update(my_list, foo = unname(foo))
test2 <- list.update(my_list, foo2 = unname(foo))

working <- my_list %>% lapply(function(x) {x$foo = unname(x$foo); x})

In the object test1 foo is still named. However in test2, new element foo2 is unnamed.
It seems like list.update is not capable of updating object themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants