Barbara.Rogo at uniroma1.it
2010-Mar-09 12:48 UTC
[R] IMPORTANT - To remove the null elements from a vector
? stato filtrato un testo allegato il cui set di caratteri non era indicato... Nome: non disponibile URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100309/39a1283b/attachment.pl>
Jorge Ivan Velez
2010-Mar-09 12:51 UTC
[R] IMPORTANT - To remove the null elements from a vector
Hi Barbara, Try x[ x != 0 ] HTH, Jorge On Tue, Mar 9, 2010 at 7:48 AM, <> wrote:> > I have a vector that have null elements. How to remove these elements? > For example: > x=[10 0 30 40 0 0] I want the vector y=[10 30 40] > Thanks > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >[[alternative HTML version deleted]]
Mario Valle
2010-Mar-09 12:51 UTC
[R] IMPORTANT - To remove the null elements from a vector
x <- x[x != 0] If for null elements you intend the value of zero. Ciao! mario On 09-Mar-10 13:48, Barbara.Rogo at uniroma1.it wrote:> > I have a vector that have null elements. How to remove these elements? > For example: > x=[10 0 30 40 0 0] I want the vector y=[10 30 40] > Thanks > [[alternative HTML version deleted]] > > ______________________________________________ > 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.-- Ing. Mario Valle Data Analysis and Visualization Group | http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
Paul Hiemstra
2010-Mar-09 13:14 UTC
[R] IMPORTANT - To remove the null elements from a vector
Barbara.Rogo at uniroma1.it wrote:> I have a vector that have null elements. How to remove these elements? > For example: > x=[10 0 30 40 0 0] I want the vector y=[10 30 40] > Thanks > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >and, to add to the options already posted: subset(x, x != 0) cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul
Matthew Dowle
2010-Mar-09 14:57 UTC
[R] IMPORTANT - To remove the null elements from a vector
Welcome to R Barbara. Its quite an incredible community from all walks of life. Your beginner questions are answered in the manual. See Introduction to R. Please read the posting guide again because it contains lots of good advice for you. Some people read it three times before posting because they have so much respect for the community. Sometimes they trip up over themselves to show they have read it. Btw - just to let you know that starting your subject lines with "IMPORTANT" is considered by some people a demanding tone for free help. Not everyone, but some people. Two posts starting IMPORTANT within 5 minutes is another thing that a very large number of people around the world may have just seen you do. I'm just letting you know, in case you were not aware of this. You received answers from four people who clearly don't mind, and you have your answers. Was that your only goal in posting? Did you consider there might be downsides? This is a public list read by many people and one thing the posting guide says is that your questions are saved in the archives forever. Just checking you knew that. I wouldn't want you to reduce your reputation accidentally. A future employer (it might be a company, or it might be a university) anywhere in the world might do a simple search on your name, and thats why you might not get an interview, because you had showed (in their minds) that you didn't have respect for guidlines. I would hate for something like that to happen, all just because you didn't know you were supposed to read the posting guide, it wouldn't be fair on you. So it would be very unfair of me to know that, and suspect that you don't, but not tell you about the posting guide, wouldn't it ? I hope this information helps you. It is entirely up to you. r-help is a great way to increase your reputation, but it can reduce your reputation too. By asking great questions, or even contributing, you can proudly put that on your CV and increase your chances of getting that interview, or getting that position. I have seen on several CVs from students the text "please search for my name on r-help". Just like everything you do in public, r-help is very similar. What you write, you write in the public domain, and you write it free of charge, and free of restriction. All this applies to all us. When asking for help, and when giving help. Matthew <Barbara.Rogo at uniroma1.it> wrote in message news:OF1A8063A1.FC14F5FF-ONC12576E1.00466053-C12576E1.0046606A at Uniroma1.it...> > I have a vector that have null elements. How to remove these elements? > For example: > x=[10 0 30 40 0 0] I want the vector y=[10 30 40] > Thanks > [[alternative HTML version deleted]] >