CodeInfoNet

Learn programming on the go!

Home » Data frames in R

Data frames in R

Data frames in R is a most essential part in this learning journey of our R programming series.

In this article we will be learning basics of data frames. At the end of this article, you will be fully aware of –

  1. What is a data frame? & How data frames are different than vectors?
  2. What operations can be performed on data frames? & What are the usages of data frames

We have already seen how to import the data into R. If you have missed it or you want to quickly make a revision, you can always refer our previous article on How to import a .csv file in R.

Let’s get started with our journey of data frames.

What is a data frame? & How data frames are different than vectors?

Data frames are the two dimensional version of the list. They are the most useful storage structure in data analysis. To make it further more simple, we can think of data frames as a Excel or spreadsheet of R. Also, it stores data in similar format.

Data frame groups vectors together into a two-dimensional table. Each vector becomes a column in the table. Lets see what operations we can perform on data frames.

What operations can be performed on data frames? And What are the usages of data frames

To learn about data frames in more proper way, we need to import data into our project.

We have MovieRatings data in a csv file. This file can be downloaded from CodeInfo’s Git repository.

setwd("H:\\CodeInfo.Net\\Github\\RProgramming")
MovieRatings <- read.csv("MovieRatings.csv")
MovieRatings

Lets get started with various operations that we can perform on data frames in R.

i. Checking if it is a data frame or not!

This is the most important and simple thing that we can do with data frames. And why not, its good to be assured of using our resources first. Here is the syntax to check our available data-

is.data.frame(MovieRatings)

So you might have understood that it is the same question as our bulleted point. We just need to write it in a format which compiler can understand.

Sumit Rajguru

Back to top