Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Read and View | Data Manipulation and Cleaning
Data Analysis with R

bookRead and View

Before you can analyze data, you need to bring it into your R environment. In most real-world scenarios, data is stored in external files or databases. The first step in any data analysis workflow is importing that data so you can begin exploring and working with it.

Common data sources

Real-world data often comes from a variety of sources, such as:

  • CSV (comma-separated values) files;
  • Excel spreadsheets;
  • Plain text (TXT) files;
  • Databases (e.g., SQL, SQLite, PostgreSQL);
  • Web APIs or other online sources.

R provides a range of functions and packages to help read data from each of these sources easily.

Reading a CSV file

CSV is one of the most commonly used formats for storing tabular data. To import a CSV file into R, we typically use a function that reads the file and stores it in a data frame - a structure that organizes data in rows and columns.

df <- read_csv("car_details.csv")

Viewing your data

Once the data is loaded, it's helpful to take a quick look at it. One simple way to do this in RStudio is with the View() function:

View(df)
question mark

Which function reads CSV files in tidyverse?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 3

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Suggested prompts:

How do I import data from other file types like Excel or TXT in R?

Can you explain more about the tidyverse package and its main functions?

What should I do if I get an error while trying to read a CSV file?

Awesome!

Completion rate improved to 4

bookRead and View

Veeg om het menu te tonen

Before you can analyze data, you need to bring it into your R environment. In most real-world scenarios, data is stored in external files or databases. The first step in any data analysis workflow is importing that data so you can begin exploring and working with it.

Common data sources

Real-world data often comes from a variety of sources, such as:

  • CSV (comma-separated values) files;
  • Excel spreadsheets;
  • Plain text (TXT) files;
  • Databases (e.g., SQL, SQLite, PostgreSQL);
  • Web APIs or other online sources.

R provides a range of functions and packages to help read data from each of these sources easily.

Reading a CSV file

CSV is one of the most commonly used formats for storing tabular data. To import a CSV file into R, we typically use a function that reads the file and stores it in a data frame - a structure that organizes data in rows and columns.

df <- read_csv("car_details.csv")

Viewing your data

Once the data is loaded, it's helpful to take a quick look at it. One simple way to do this in RStudio is with the View() function:

View(df)
question mark

Which function reads CSV files in tidyverse?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 3
some-alt