BaşlayınÜcretsiz Başlayın

Naming your columns / rows

Let's look at cash again:

cash

  comp cash yr
1    A 1000  1
2    A 4000  3
3    A  550  4
4    B 1500  1
5    B 1100  2
6    B  750  4
7    B 6000  5

Wait, that's not right! It looks like someone has changed your column names! Don't worry, you can change them back using colnames() just like you did with names() back with vectors.

Similarly, you can change the row names using rownames(), but this is less common.

Bu egzersiz

Introduction to R for Finance

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • The altered data frame cash is in your workspace.
  • Fix your column names by using colnames() and assigning a character vector of "company", "cash_flow", and "year" in that order.
  • Print out the fixed colnames() of cash.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Fix your column names


# Print out the column names of cash
Kodu Düzenle ve Çalıştır