[R] Extending each element in a list, or rbind()-ing arrays of different length without recycling
Wacek Kusnierczyk
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Thu Feb 12 22:48:21 CET 2009
markleeds at verizon.net wrote:
> Thanks Rolf. very nice but "pretty easy" is ALWAYS a relative statement.
>
right. it's even "easier":
na.last = function(x) {
na = is.na(x)
c(x[!na], x[na]) }
>
>
> On Thu, Feb 12, 2009 at 3:59 PM, Rolf Turner wrote:
>
>> On 13/02/2009, at 9:06 AM, markleeds at verizon.net wrote:
>>
>>> Hi Jason: below seems to work. you have to take the transpose because
>>> the apply
>>> returns the rows transposed. i'm also not sure how to make the NAs be
>>> the last
>>> ones but maybe someone can show us how to do that.
>>
>> Pretty easy:
>>
>> na.at.end <- function(x){
>> i <- is.na(x)
>> c(x[!i],rep(NA,sum(i)))
>> }
More information about the R-help
mailing list