Re: [R] Find the indices of non-NA elements of a sequence

2013-05-17 Thread Pascal Oettli
Hi, For example: > which(complete.cases(test)) [1] 1 3 4 6 Probably a more elegant way exists. Regards, Pascal 2013/5/17 jpm miao > Hi, > > I have a sequence whose 1st, 3rd, 4th, 6th are non-NAs. How could I let R > return 1,3,4,6, the indices? > > I know only how to find the non-NA ele

Re: [R] Find the indices of non-NA elements of a sequence

2013-05-16 Thread Berend Hasselman
On 17-05-2013, at 08:36, jpm miao wrote: > Hi, > > I have a sequence whose 1st, 3rd, 4th, 6th are non-NAs. How could I let R > return 1,3,4,6, the indices? > > I know only how to find the non-NA elements. Thanks, > > Miao > >> test<-c(2,NA,6,8,NA,12) >> test[is.na(test)==FALSE] > [1] 2 6

[R] Find the indices of non-NA elements of a sequence

2013-05-16 Thread jpm miao
Hi, I have a sequence whose 1st, 3rd, 4th, 6th are non-NAs. How could I let R return 1,3,4,6, the indices? I know only how to find the non-NA elements. Thanks, Miao > test<-c(2,NA,6,8,NA,12) > test[is.na(test)==FALSE] [1] 2 6 8 12 [[alternative HTML version deleted]] __