After you have successfully imported your data into R, I would recommend doing 5 quick checks before you start with the analysis. In this example I’m using the dataset iris, which comes pre-loaded in R.
Dimension
Check the dimensions (i.e., the number of rows and columns) of your dataset by using the function dim(). Here we see that iris has 150 rows and 5 columns.
dim(iris) 150 5
Names
Identify the names of the variables in your dataset.
names(iris) "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
Structure
Get information about the structure of the dataset (i.e., whether each variable is numeric or a factor).
str(iris) 'data.frame': 150 obs. of 5 variables: $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ... $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ... $ Species : Factor w/ 3 levels "setosa","versicolor",..
Header
Look at the header (the first rows) of your dataset to get an idea of the variables and their values.
head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa
Missing values
Look for missing data. Here we use the functions sum and mean to summarize the missing values: sum gives the number of missing values, and mean gives the proportion of values that are missing.
sum(is.na(iris$Sepal.Length)) mean(is.na(iris$Sepal.Length)) 0 0
Both return 0, which means the variable Sepal.Length has no missing values.
Those are the first things I usually do after I load a dataset into R.