Find the empty element in a factor array

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Find the empty element in a factor array

Wendy
Hi all,

I have a factor array, and some of the elements are empty. How would I return the index number of the empty elements. For example,

test<-factor(c('A','','B','C','E'))
> test
[1] A   B C E
Levels:  A B C E

I would like the result equal to 2.

Thank you,
Wendy
Reply | Threaded
Open this post in threaded view
|

Re: Find the empty element in a factor array

Peter Alspach-2
Tena koe Wendy

which(test=='')

Should do it.

HTH ....

Peter Alspach

> -----Original Message-----
> From: [hidden email] [mailto:r-help-bounces@r-
> project.org] On Behalf Of Wendy
> Sent: Thursday, 27 January 2011 10:59 a.m.
> To: [hidden email]
> Subject: [R] Find the empty element in a factor array
>
>
> Hi all,
>
> I have a factor array, and some of the elements are empty. How would I
> return the index number of the empty elements. For example,
>
> test<-factor(c('A','','B','C','E'))
> > test
> [1] A   B C E
> Levels:  A B C E
>
> I would like the result equal to 2.
>
> Thank you,
> Wendy
> --
> View this message in context: http://r.789695.n4.nabble.com/Find-the-
> empty-element-in-a-factor-array-tp3238894p3238894.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.