There have been several solutions like:
k[k != 3]
The more general form of this idea is:
k[!(k %in% 3)]
Sticking closer to the original form would be:
out <- which(k == 3)
if(length(out)) k[-out] else k
Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
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
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.
______________________________________________
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.