LoslegenKostenlos loslegen

Accessing and subsetting data frames (1)

Even more often than with vectors, you are going to want to subset your data frame or access certain columns. Again, one of the ways to do this is to use [ ]. The notation is just like matrices! Here are some examples:

Select the first row: cash[1, ]

Select the first column: cash[ ,1]

Select the first column by name: cash[ ,"company"]

Diese Übung ist Teil des Kurses

Introduction to R for Finance

Kurs anzeigen

Anleitung zur Übung

  • Select the third row and second column of cash.
  • Select the fifth row of the "year" column of cash.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Third row, second column


# Fifth row of the "year" column
Code bearbeiten und ausführen