[R] how to remove an element from list or character

Milan Bouchet-Valat nalimilan at club.fr
Fri Jan 6 11:05:26 CET 2012


Le jeudi 05 janvier 2012 à 23:52 -0800, arunkumar1111 a écrit :
> HI 
> 
> I want to remove an element from a list or character. i can any of the class
> type
> 
> like
> 
> cat=  [1] "mac" "med"
> 
> if my input is 2 i need to remove med and if my input is one i need to
> remove mac from cat
This is really basic, please read the R intro or some tutorial.

Basically, you can do:
input <- 1 (or input <- 2)
cat <- cat[-input]


Cheers



More information about the R-help mailing list