Quantcast

How to count the number of occurence?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to count the number of occurence?

TJ-2
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to count the number of occurence?

David Winsemius

On Mar 20, 2010, at 3:43 AM, tj wrote:

>
> Hi, may I ask for your help...
> What is the R code if I want to count the number of times that "2"  
> appeared
> in the following R output
>
>> k
> [1] 1 1 1 1 1 1 3 1 2 1 1 1 1 1 1 1 1 3 2 1 1 4 1 1 1 1 1 5 1 1

sum(k==2)

>
>

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to count the number of occurence?

jholtman
In reply to this post by TJ-2
use table and count all occurances at one time

> X
 [1] 1 1 1 1 1 1 3 1 2 1 1 1 1 1 1 1 1 3 2 1 1 4 1 1 1 1 1 5 1 1
> table(X)
X
 1  2  3  4  5
24  2  2  1  1
>


On Sat, Mar 20, 2010 at 3:43 AM, tj <[hidden email]> wrote:

>
> Hi, may I ask for your help...
> What is the R code if I want to count the number of times that "2" appeared
> in the following R output
>
> > k
>  [1] 1 1 1 1 1 1 3 1 2 1 1 1 1 1 1 1 1 3 2 1 1 4 1 1 1 1 1 5 1 1
>
>
>
>
> Thank you for your help. :-)
> --
> View this message in context:
> http://n4.nabble.com/How-to-count-the-number-of-occurence-tp1661733p1661733.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
>  [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



--
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to count the number of occurence?

TJ-2
This post was updated on .
In reply to this post by TJ-2
CONTENTS DELETED
The author has deleted this message.
Loading...