On 4 January 2013 17:47, Bert Gunter wrote:
> Inline.
>
> On Fri, Jan 4, 2013 at 7:44 AM, Suzen, Mehmet wrote:
>>
>> I am always reserved about types and not sure how R auto casting works
>> internally.
>> In a large code using many different packages, I think being reserved
>> about
>> this woul
#[1] 6
> > length(which(abs(test) < .Machine$double.xmin))
> > #[1] 6
> > A.K.
> >
> >
> >
> >
> > ----- Original Message -
> > From: "Suzen, Mehmet"
> > To: Hermann Norpois
> > Cc: R help
> > Sent: Friday, Ja
in))
#[1] 6
A.K.
- Original Message -
From: "Suzen, Mehmet"
To: Hermann Norpois
Cc: R help
Sent: Friday, January 4, 2013 12:27 AM
Subject: Re: [R] count appearence of zero in a vector
Hi Hermann,
You may want to use ?which, to store the index as well (might be handy
in debugging or som
t)<1))
> #[1] 6
> length(which(abs(test) < .Machine$double.xmin))
> #[1] 6
> A.K.
>
>
>
>
> - Original Message -
> From: "Suzen, Mehmet"
> To: Hermann Norpois
> Cc: R help
> Sent: Friday, January 4, 2013 12:27 AM
> Subject: Re: [R] c
Hi Hermann,
You may want to use ?which, to store the index as well (might be handy
in debugging or some other
purposes if zeros has some special meaning) :
test <- c(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)
length(which(test==0))
But be careful
appearence of zero in a vector
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.
Very simple. And great.
Thanks.
2013/1/3 Sarah Goslee
> sum(test == 0)
>
> On Thu, Jan 3, 2013 at 5:49 PM, Hermann Norpois
> 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
sum(test == 0)
On Thu, Jan 3, 2013 at 5:49 PM, Hermann Norpois 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==
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?
Tha
9 matches
Mail list logo