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

Computing the summary and the str() function for a single variable

When factor summaries are combined with those for numerical variables (as in the earlier example), summary() gives counts for a maximum of six levels and lumps the other counts under Other.

You can invoke summary() and the str() function for a single variable as well. In such a case, the summary you get for numerical variables remains as before, but for factors, you get counts for many more levels:

> summary(auto$cylinders)> summary(auto$mpg)> str(auto$cylinders)

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