O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Counting groups

We can easily count the number of rows in each group, as follows:

> autoDT[,.N ,by=cylinders] 
   cylinders   N 
1:      3cyl   4 
2:      4cyl 204 
3:      5cyl   3 
4:      6cyl  84 
5:      8cyl 103 

We can also count after subsetting, as follows:

> autoDT["4cyl",.N] 
[1] 204 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required