Message-ID: <CAM_vjumXNY3SNE3qRMUpbHMGqbeQDx1xg_xZ4MszJnOycYNfWg@mail.gmail.com>
Date: 2013-01-03T22:57:57Z
From: Sarah Goslee
Subject: count appearence of zero in a vector
In-Reply-To: <CAKyZeBvAt62kpu8k9hPbPHX_cKs_-G_kYKDreD5sLiscJM7b0w@mail.gmail.com>
sum(test == 0)
On Thu, Jan 3, 2013 at 5:49 PM, Hermann Norpois <hnorpois at googlemail.com> wrote:
> Hello,
>
> I wish to count how often zero (0) appears in the vector test.
>
> test
> [1] 1 1 1 1 1 1 2 1 1 1 0 2 0 1 1 0 0 0 1 1 1 0 1 2 1 1 1 1 1 1
>
>
> I think of something like ...
>
>> sapply (test, function (x) if (x==0 ...
>
> ... but actually I dont know how to carry on.
>
> Could anybody give me a hint?
>
> Thanks Hermann
>
---
Sarah Goslee
http://www.functionaldiversity.org