On 5/14/2008 11:16 AM, Shubha Vishwanath Karanth wrote:
Hi R,

Suppose

l=c(1,1,1,2,2,1,1,1)

k[-which(k==1)]

[1] 2 2

k[-which(k==2)]

[1] 1 1 1 1 1 1

But,

k[-which(k==3)]

numeric(0)

I do not want this numeric(0), instead the whole k itself should be my
result... How do I do this?

Thanks,

Shubha

Look at the result of which(k==3) to see why your approach does not work. You might try this instead:

k <- c(1,1,1,2,2,1,1,1)

k[!(k==1)]

[1] 2 2

k[!(k==2)]

[1] 1 1 1 1 1 1

k[!(k==3)]

[1] 1 1 1 2 2 1 1 1

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

______________________________________________
R-help@r-project.org 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.

--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

______________________________________________
R-help@r-project.org 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.

Reply via email to