; , "ce" ,
r-help@r-project.org
Subject: Re: [R] lapply returns NULL ?
I think that removing them is something the OP doesn't understand how to do.
The lapply function ALWAYS produces an output element for every input element.
If this is not what you want then you need to choose
Thanks Jeff et. all,
This is exactly what I needed.
-Original Message-
From: "Jeff Newmiller" [jdnew...@dcn.davis.ca.us]
Date: 07/12/2014 10:38 AM
To: "Uwe Ligges" , "ce" ,
r-help@r-project.org
Subject: Re: [R] lapply returns NULL ?
I think that rem
I think that removing them is something the OP doesn't understand how to do.
The lapply function ALWAYS produces an output element for every input element.
If this is not what you want then you need to choose a looping structure that
is not so tightly linked to the input, such as a for loop (unt
Hello,
Try the following.
res <- lapply(foo, function(x) if(x[1] == 1 ) x )
res[!sapply(res, is.null)]
Hope this helps,
Rui Barradas
Em 12-07-2014 14:25, ce escreveu:
Dear all,
I have a list of arrays :
foo<-list(A = c(1,3), B =c(1, 2), C = c(3, 1))
foo
$A
[1] 1 3
$B
[1] 1 2
$C
[1
On 12.07.2014 15:25, ce wrote:
Dear all,
I have a list of arrays :
foo<-list(A = c(1,3), B =c(1, 2), C = c(3, 1))
foo
$A
[1] 1 3
$B
[1] 1 2
$C
[1] 3 1
if( foo$C[1] == 1 ) foo$C[1]
lapply(foo, function(x) if(x[1] == 1 ) x )
$A
[1] 1 3
$B
[1] 1 2
$C
NULL
I don't want to lis
Dear all,
I have a list of arrays :
foo<-list(A = c(1,3), B =c(1, 2), C = c(3, 1))
> foo
$A
[1] 1 3
$B
[1] 1 2
$C
[1] 3 1
> if( foo$C[1] == 1 ) foo$C[1]
> lapply(foo, function(x) if(x[1] == 1 ) x )
$A
[1] 1 3
$B
[1] 1 2
$C
NULL
I don't want to list $C NULL in the output. How I can
6 matches
Mail list logo