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

Abhinav Agarwal

Graduate Student at Northwestern University
linkedin profile url

I come from Northwestern University, which is ranked 9th in the US. Although the high-quality academics at school taught me all the basics I needed, obtaining practical experience was a challenge.... 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 Review Classification Model using Gated Recurrent Unit
In this Machine Learning project, you will build a classification model in python to classify the reviews of an app on a scale of 1 to 5 using Gated Recurrent Unit.

Build Real Estate Price Prediction Model with NLP and FastAPI
In this Real Estate Price Prediction Project, you will learn to build a real estate price prediction machine learning model and deploy it on Heroku using FastAPI Framework.

NLP Project on LDA Topic Modelling Python using RACE Dataset
Use the RACE dataset to extract a dominant topic from each document and perform LDA topic modeling in python.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

Recommender System Machine Learning Project for Beginners-4
Collaborative Filtering Recommender System Project - Comparison of different model based and memory based methods to build recommendation system using collaborative filtering.

Word2Vec and FastText Word Embedding with Gensim in Python
In this NLP Project, you will learn how to use the popular topic modelling library Gensim for implementing two state-of-the-art word embedding methods Word2Vec and FastText models.

BERT Text Classification using DistilBERT and ALBERT Models
This Project Explains how to perform Text Classification using ALBERT and DistilBERT

Insurance Pricing Forecast Using XGBoost Regressor
In this project, we are going to talk about insurance forecast by using linear and xgboost regression techniques.

Build a Face Recognition System in Python using FaceNet
In this deep learning project, you will build your own face recognition system in Python using OpenCV and FaceNet by extracting features from an image of a person's face.