Why is loading data the first step in any data analysis process in R?
Think about what you need before you can start working.
Data loading is essential because it brings the information into R that you want to work with. Without data, analysis or visualization cannot happen.
What will be the output of this R code?
data <- read.csv(text = 'name,age\nAlice,30\nBob,25') print(nrow(data))
Count the number of rows in the loaded data.
The CSV text has two rows of data (Alice and Bob), so nrow(data) returns 2.
What error will this R code produce?
data <- read.csv('nonexistentfile.csv')
print(head(data))Think about what happens if the file does not exist.
Trying to read a file that does not exist causes an error about failing to open the connection.
What will be the output of this R code?
data <- read.csv(text = 'name,age\nAlice,30\nBob,') print(is.na(data$age))
Check how R treats missing numeric values in CSV.
The second row has a missing age, so is.na returns TRUE for that entry and FALSE for the first.
Why must data be loaded before cleaning or transforming it in R?
Think about what cleaning means and what it needs.
Cleaning means changing or fixing data. Without loading data first, there is nothing to clean.