[R] A very simple question

Erin Hodgess erinm.hodgess at gmail.com
Thu May 15 09:41:30 CEST 2008


Or

> k <- c(1,1,1,2,2,1,1)
> k[!(k==3)]
[1] 1 1 1 2 2 1 1
>


On Wed, May 14, 2008 at 1:59 PM, Julian Burgos
<jmburgos at u.washington.edu> wrote:
> Try this:
>
> 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
>
> Julian
>
>
> 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 at 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 at 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.
>



-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com



More information about the R-help mailing list