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

rlist functions report error when the first element is NULL #118

Open
happyshows opened this issue Dec 17, 2016 · 1 comment
Open

rlist functions report error when the first element is NULL #118

happyshows opened this issue Dec 17, 2016 · 1 comment

Comments

@happyshows
Copy link

Please see example below, I tried list.map and list.first, I'm pretty sure it applies to most of the functions.

I'm wondering if this is an expected behavior.

Having a NULL as the first element of the List of List could happen when I am saving the interim filtered result. Applying list.clean before any operation I want to do seems to be a bit excessive.

Can you suggest a better way of handling my situation?

> t <- list(a = NULL, b = list(x=1,y=2),c=list(x=2,y=5,z=4))
> t1 <- list(b = list(x=1,y=2),c=list(x=2,y=5,z=4))
> t %>% list.map(y)
Error in eval(expr, envir, enclos) : object 'y' not found
> t1 %>% list.map(y)
$b
[1] 2

$c
[1] 5

> t %>% list.first()
NULL
> t1 %>% list.first()
$x
[1] 1

$y
[1] 2
@renkun-ken
Copy link
Owner

I suggest that you use list.filter to exclude the elements in which y is not available before using list.map.

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

2 participants