[R] RStudio 1.1.453 - Windows 10 - How to subset named vector by names that are NOT "foo"

إبراهيم خطاب Ibrauheem Khat'taub b@rhomopo||@ @end|ng |rom gm@||@com
Tue Jul 31 19:55:46 CEST 2018


Awesome, thanks!
مع خالص الشكر والسلام عليكم.
إبراهيم خطاب


On Tue, 31 Jul 2018 at 13:54, Data Science Classes <
datascienceclasses using gmail.com> wrote:

> You can do
>
> Vect[-grep (“foo”, names(vect))]
>
> On Tue, 31 Jul 2018 at 11:12 PM, إبراهيم خطاب Ibrauheem Khat'taub <
> barhomopolis using gmail.com> wrote:
>
>> H
>> i All,
>>
>> If I have this vector:
>>
>> > vect <- c(foo = 11, bar = 2, norf = 45)
>>
>> I can have a subset that has only "bar and "norf" this way:
>> > vect[c("bar","norf")]
>>
>> Now how do I achieve the same by asking it for a subset that simply
>> excludes "foo"? I tried all these, resulting in errors:
>>
>> vect[-"foo"]
>> vect[-c("foo")]
>> vect[!"foo"]
>> vect[!c("foo")]
>>
>> Thanks!
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
> --
> Regards,
> Data Science Classes
>

	[[alternative HTML version deleted]]




More information about the R-help mailing list