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.

Explore Interesting IoT Project Ideas for Practice

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 = )

Where:

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

object.size(z)

256 bytes

Note:

  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.

What Users are saying..

profile image

Savvy Sahai

Data Science Intern, Capgemini
linkedin profile url

As a student looking to break into the field of data engineering and data science, one can get really confused as to which path to take. Very few ways to do it are Google, YouTube, etc. I was one of... Read More

Relevant Projects

Time Series Project to Build a Multiple Linear Regression Model
Learn to build a Multiple linear regression model in Python on Time Series Data

Build a Credit Default Risk Prediction Model with LightGBM
In this Machine Learning Project, you will build a classification model for default prediction with LightGBM.

BigMart Sales Prediction ML Project in Python
The goal of the BigMart Sales Prediction ML project is to build and evaluate different predictive models and determine the sales of each product at a store.

Llama2 Project for MetaData Generation using FAISS and RAGs
In this LLM Llama2 Project, you will automate metadata generation using Llama2, RAGs, and AWS to reduce manual efforts.

Build an Image Segmentation Model using Amazon SageMaker
In this Machine Learning Project, you will learn to implement the UNet Architecture and build an Image Segmentation Model using Amazon SageMaker

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

Mastering A/B Testing: A Practical Guide for Production
In this A/B Testing for Machine Learning Project, you will gain hands-on experience in conducting A/B tests, analyzing statistical significance, and understanding the challenges of building a solution for A/B testing in a production environment.

Build a CNN Model with PyTorch for Image Classification
In this deep learning project, you will learn how to build an Image Classification Model using PyTorch CNN

Build Portfolio Optimization Machine Learning Models in R
Machine Learning Project for Financial Risk Modelling and Portfolio Optimization with R- Build a machine learning model in R to develop a strategy for building a portfolio for maximized returns.

Build a Multi ClassText Classification Model using Naive Bayes
Implement the Naive Bayes Algorithm to build a multi class text classification model in Python.