MulaiMulai sekarang secara gratis

read.delim

Aside from .csv files, there are also the .txt files which are basically text files. You can import these files with read.delim(). By default, it sets the sep argument to "\t" (fields in a record are delimited by tabs) and the header argument to TRUE (the first row contains the field names).

In this exercise, you will import hotdogs.txt (view), containing information on sodium and calorie levels in different hotdogs (Source: UCLA). The dataset has 3 variables, but the variable names are not available in the first line of the file. The file uses tabs as field separators.

Latihan ini adalah bagian dari kursus

Introduction to Importing Data in R

Lihat Kursus

Petunjuk latihan

  • Import "hotdogs.txt" with read.delim(). Call the resulting data frame hotdogs. The variable names are not on the first line, so make sure to set the header argument appropriately.
  • Call summary() on hotdogs. This will print out some summary statistics about all variables in the data frame.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Import "hotdogs.txt": hotdogs
hotdogs <- ___

# Summarize hotdogs
___
Edit dan Jalankan Kode