[R] removal of an element from a vector

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Wed Jan 4 10:38:03 CET 2006


try the following:

x <- c(120, 235, 172, 95, 175, 200, 233, 142)
y <- x[x < 100]
z <- x[x >= 100]

x
y
z

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "gynmeerut" <gynmeerut at indiatimes.com>
To: "R-Stat Help" <R-help at stat.math.ethz.ch>
Sent: Wednesday, January 04, 2006 10:22 AM
Subject: [R] removal of an element from a vector


>
> Dear All,
>  I have some problem in R which I'm explaining using an example:
> x<-(120,235,172,95,175,200,233,142)
> i want to remove the elements which are lesser than 100 and as a 
> result i want two vectors
>
> y<-(containing elements <100)
> z<-(remaining elements)
>
>
> Moreover if I wish to use two different programs for vectors y and 
> z.
> which command shall I use(will IF-ELSE  work ?)
>
>
>
> Thanks and regards,
>
> GS
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm




More information about the R-help mailing list