Read 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)
Tak for dine kommentarer!
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Awesome!
Completion rate improved to 4
Read and View
Stryg for at vise menuen
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)
Tak for dine kommentarer!