Count points based on unique values in column
<p><strong>EDIT:</strong>
below was extremely useful, so I've been playing around with this for a few hours. Eventually I ended up trying something that didn't work: from the mean of the points per id, I tried to only include the last (for example) 5 clicks/pageviews per id. The code I used is:</p>

<blockquote>
  <p>megatest&lt;-aggregate(points ~ session_id, pointsperid, mean, FUN=tail, n=5)</p>
</blockquote>

<p>However, it only produces a table looking like:</p>

<pre><code>id    points
1     c(20,0)
2     c(20,10,20,100,20)
</code></pre>

<p>Instead of summing them and producing the mean. I'm curious, is there any way to work around this? Thanks in advance! (and apologies for so many new questions in this question, but R is getting me really excited).</p>

<hr>

<p>Hi experienced R users,</p>

<p>I'm new to R, so my apologies if the answer is straightforward or if I'm not being clear. </p>

<p>I created a dataframe of about 500,000 observations of clickstream data across 16 variables. Two of these columns are 'id' and 'assigned points'</p>

<p>Where 'id' indicates an internet session id, and 'points' the number of points I assigned to each click/pageview (it could be that some clicks do not have a number of points assigned), so for example:</p>

<pre><code>id   points
1    10
1    N/A
1    30
2    100
3    20
3    10
</code></pre>

<p>Within the 'id' column, there are about 60000 unique values. What I want to achieve is, to count the number of points assigned to each 'id', and to let R do this automatically for all unique ids. So I'm looking for a result such as:</p>

<pre><code>1 [40], 2 [100], 3[30]
</code></pre>

<p>However, I have absolutely no clue how to tell R to identify all unique ids and to do something (i.e. count points) within all these unique ids. </p>

<p>All help would be extremely appreciated! Thanks in advance!</p>