The first step in any kind of data analysis in R is to load data, that is, to import a dataset into the environment. Before that, we have to figure out the type of data file and choose appropriate tools to read the data.
Among all the file types used to store data, perhaps the most widely used one is CSV. In a typical CSV file, the first line is the header of columns, and each subsequent line represents a data record with columns separated by commas. Here is an example of student records written in this format:
Name,Gender,Age,Major Ken,Male,24,Finance Ashley,Female,25,Statistics Jennifer,Female,23,Computer Science
RStudio provides an interactive way to import data. You can navigate to Tools | Import Dataset | From Local File and choose a local file in a text format, such as .csv
and .txt
. Then, you can adjust the parameters and preview the resulting data frame:
Note that you should check Strings...