Useful functions for working with data objects in R

We have seen different data structures in R. Now let’s see some useful functions for working with these data objects.

Functions Purpose
length(x) Number of elements/components.
dim(x) Dimensions of x.
str(x) Structure of x.
class(x) Class or type of x.
mode(x) How x is stored.
names(x) Names of components in x.
c(x1, x2,...) Combines x1,x2 into a vector.
cbind(x1, x2, ...) Combines x1,x2 as columns.
rbind(x1, x2, ...) Combines x1,x2 as rows.
x Prints the x.
head(x) Lists the first part of the x.
tail(x) Lists the last part of the x.
ls() Lists current objects.
rm(x1, x2, ...) Deletes one or more objects. The statement
rm(list = ls()) will remove most objects
from the working environment.
y <- edit(x) Edits x and saves as y.
fix(x) Edits in place.

If I have missed any functions, Let me know in the comment section below.

Previous articleData structures in R – Part 2
Next articleImporting data from SPSS in R
Author and Assistant Professor in Finance, Ardent fan of Arsenal FC. Always believe "The only good is knowledge and the only evil is ignorance - Socrates"
Notify of
Inline Feedbacks
View all comments