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

Assigning column names

You’ve probably noticed that the hotdogs.txt file lacks column names, and R has assigned default, random names to the columns.

To make the data more understandable and easier to work with, you can assign appropriate column names while reading the file into R.

head(hotdogs)
    V1  V2  V3
1 Beef 186 495
2 Beef 181 477
3 Beef 176 425
4 Beef 149 322
5 Beef 184 482
6 Beef 190 587

Bu egzersiz

Introduction to Importing Data in R

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

Egzersiz talimatları

  • Complete the read.delim() function call by assigning the column names to "type", "calories", and "sodium".

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Finish the read.delim() call
hotdogs <- read.delim("hotdogs.txt", header = FALSE, col.names = ___)

# Print the first 6 rows of hotdogs
head(hotdogs)
Kodu Düzenle ve Çalıştır