Re: [R] count appearence of zero in a vector

2013-01-04 Thread Suzen, Mehmet
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

Re: [R] count appearence of zero in a vector

2013-01-04 Thread Bert Gunter
#[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

Re: [R] count appearence of zero in a vector

2013-01-04 Thread arun
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

Re: [R] count appearence of zero in a vector

2013-01-04 Thread Suzen, Mehmet
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

Re: [R] count appearence of zero in a vector

2013-01-03 Thread Suzen, Mehmet
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

Re: [R] count appearence of zero in a vector

2013-01-03 Thread arun
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.

Re: [R] count appearence of zero in a vector

2013-01-03 Thread Hermann Norpois
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

Re: [R] count appearence of zero in a vector

2013-01-03 Thread 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 > > > I think of something like ... > >> sapply (test, function (x) if (x==

[R] count appearence of zero in a vector

2013-01-03 Thread Hermann Norpois
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