How to find size of an object in R?

How to find size of an object in R?

How to find size of an object in R?

This recipe helps you find size of an object in R


Recipe Objective

A solid understanding of memory management in any programming language is crucial to accurately predict the memory required for a given task as well as to make the most of the memory we have. Additionally, it also helps us execute our code faster by avoiding duplication in memory space.

In this recipe, you will learn how to find the size of an object in or how much memory an object occupies in R. ​

STEP 1: Creating a list object

Creating a heterogenous list

z = list(1:5,"a10")

STEP 2:Finding the size of an R object (list)

We will use built-in function object.size() to carry out this task. This function just gives you an estimation of the memory that is stored.

Syntax: object.size(x, units = )


  1. x = an R object
  2. units = (optional) units to be used for formatting and printing the size
256 bytes


  1. The calculation is only of the size of the object and does not include the space required to store it's name.
  2. 64-bits build have larger object sizes than 32-bits one.

Relevant Projects

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Demand prediction of driver availability using multistep time series analysis
In this supervised learning machine learning project, you will predict the availability of a driver in a specific area by using multi step time series analysis.

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Expedia Hotel Recommendations Data Science Project
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.