O'Reilly logo

Data Analysis with R - Second Edition by Tony Fischetti

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

Using both i and j

Let’s combine what we’ve learned about the first two-thirds of the allowable square bracket expressions by using both i and j in the same statements, as shown in the following code:

> tracks[artist=="Belle and Sebastian", trackname][1] "A Century Of Elvis" "A Century Of Elvis" "Dog On Wheels"...> tracks[artist=="Belle and Sebastian", .(artist, trackname)]                   artist                             trackname   1: Belle and Sebastian                    A Century Of Elvis   2: Belle and Sebastian                    A Century Of Elvis   3: Belle and Sebastian                         Dog On Wheels   4: Belle and Sebastian                         Dog On Wheels   5: Belle and Sebastian                    The Power Of Three  ---                                                         5553: Belle and Sebastian                               Fiction5554: Belle and Sebastian                    Your Cover’s Blown5555: Belle and Sebastian         I Don’t Want To Play Football5556: Belle and Sebastian ...

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