Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Reading and Inspecting Data | Data Preparation and Cleaning
R for Data Scientists

bookReading and Inspecting Data

Prerequisites
Pré-requisitos

Before you can analyze or visualize data in R, you need to bring your data into your R environment. Most often, data comes in text-based formats like CSV (comma-separated values) files. Loading these files and inspecting their structure helps you understand what variables are available, their types, and whether any cleaning is needed before further analysis. This foundational step ensures you work with accurate, well-understood data throughout your project.

123456
library(readr) # Load a CSV file into a tibble data <- read_csv("https://staging-content-media-cdn.codefinity.com/courses/dd47061a-6da5-4e45-add5-cea0af087f14/iris_data.csv", show_col_types=FALSE) print(as.data.frame(data))
copy

The library(readr) line loads the readr package, which provides the read_csv() function for efficient CSV file reading. The function call read_csv("data/iris.csv") reads the file named "iris.csv" from the "data" folder. The result is stored in the variable data, which is a tibble — a modern, user-friendly version of a data frame. This tibble automatically detects column names and types, displaying a clean preview when printed. By inspecting the first few rows and column types, you can confirm the data loaded correctly and begin exploring further.

Note
Note

Be careful with file paths — if R cannot find your file, check that the path is correct relative to your current working directory. CSV files with non-UTF-8 encoding may cause errors or misread characters; specify the encoding if needed. Also, missing values in your CSV may appear as NA in R, but sometimes they are coded differently (like empty strings or specific text). Always inspect your data after import to catch these issues early.

question mark

Which statements about reading and inspecting CSV data in R are correct?

Select all correct answers

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 1

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

bookReading and Inspecting Data

Deslize para mostrar o menu

Prerequisites
Pré-requisitos

Before you can analyze or visualize data in R, you need to bring your data into your R environment. Most often, data comes in text-based formats like CSV (comma-separated values) files. Loading these files and inspecting their structure helps you understand what variables are available, their types, and whether any cleaning is needed before further analysis. This foundational step ensures you work with accurate, well-understood data throughout your project.

123456
library(readr) # Load a CSV file into a tibble data <- read_csv("https://staging-content-media-cdn.codefinity.com/courses/dd47061a-6da5-4e45-add5-cea0af087f14/iris_data.csv", show_col_types=FALSE) print(as.data.frame(data))
copy

The library(readr) line loads the readr package, which provides the read_csv() function for efficient CSV file reading. The function call read_csv("data/iris.csv") reads the file named "iris.csv" from the "data" folder. The result is stored in the variable data, which is a tibble — a modern, user-friendly version of a data frame. This tibble automatically detects column names and types, displaying a clean preview when printed. By inspecting the first few rows and column types, you can confirm the data loaded correctly and begin exploring further.

Note
Note

Be careful with file paths — if R cannot find your file, check that the path is correct relative to your current working directory. CSV files with non-UTF-8 encoding may cause errors or misread characters; specify the encoding if needed. Also, missing values in your CSV may appear as NA in R, but sometimes they are coded differently (like empty strings or specific text). Always inspect your data after import to catch these issues early.

question mark

Which statements about reading and inspecting CSV data in R are correct?

Select all correct answers

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 1
some-alt