Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • R High Performance Programming
  • Toc
  • feedback
R High Performance Programming

R High Performance Programming

By : Aloysius Shao Qin Lim, Tjhi W Chandra
4.4 (14)
close
R High Performance Programming

R High Performance Programming

4.4 (14)
By: Aloysius Shao Qin Lim, Tjhi W Chandra

Overview of this book

This book is for programmers and developers who want to improve the performance of their R programs by making them run faster with large data sets or who are trying to solve a pesky performance problem.
Table of Contents (12 chapters)
close
11
Index

Removing intermediate data when it is no longer needed


In large R programs, objects are created in many places. Often, an object that is created in an earlier part of the program is not needed in later parts of the program. When faced with memory limits, it is useful to free up memory taken up by objects when they are no longer needed, so that subsequent parts of the program can run successfully.

The main tool for this is the rm() function that removes a given list of objects from the current R environment.

In the following example, we have a data frame containing 500,000 transactions from a retail store and the items within each transaction. Each row of the data frame represents a unique transaction-item pair that occurred in a sales database. Although, we have to generate the data for this example in a real business context, this data could be extracted from a retailer's sales database:

trans.lengths <- rpois(5e5, 3) + 1L
trans <- rep.int(1:5e5, trans.lengths)
items <- unlist(lapply...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete