Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Modern R Programming Cookbook
Modern R Programming Cookbook

Modern R Programming Cookbook: Recipes to simplify your statistical applications

Arrow left icon
Profile Icon Jaynal Abedin
Arrow right icon
R$80 R$218.99
eBook Oct 2017 236 pages 1st Edition
eBook
R$80 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m
Arrow left icon
Profile Icon Jaynal Abedin
Arrow right icon
R$80 R$218.99
eBook Oct 2017 236 pages 1st Edition
eBook
R$80 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m
eBook
R$80 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Modern R Programming Cookbook

Data Structures in R

In this chapter, you will learn about the data structures of R and how to create and access its properties, and various operations related to a specific data structure. The following recipes will be covered in this chapter:

  • Creating a vector and accessing its properties
  • Creating a matrix and accessing its properties
  • Creating a data frame and accessing its properties
  • Creating an array and accessing its properties
  • Creating a list from a combination of vector, matrix, and data frames
  • Converting a matrix to a data frame and a data frame to a matrix

Introduction

To use R most efficiently and effectively, you must understand the data types and data structures of R, because the Machine Learning algorithms such as Support Vector Machine (SVM), decision tree, and even linear regression and logistic regression have optimization components. The use of the correct data types is the key part of the performance of optimization. Also, to perform matrix operations, the user must use matrix data types. Moreover, the user needs to know the use of correct variables into the statistical model, and understanding R data types is the important aspect in this area. Here are the data types that will help you store and manage your data correctly and efficiently:

  • Character
  • Numeric
  • Logical
  • Integer
  • Complex

The data structure of R is the way to organize the dataset for data storage and analytics purposes. Each of the different data structures can...

Creating a vector and accessing its properties

In this recipe, you will learn what a vector is in R, and how to create it, access its properties, and perform certain operations.

Getting ready

To follow this recipe, you need the R software installed on your computer. Before going to the next step, you have to understand the definition of a vector in R. In R, a vector is simply a collection of values with the same type; it could be all character, numeric, or logical. For example, it could contain names of places/countries, it could contain the number of hours a person spends on the internet over the last seven days, or it could also contain whether a group of people has a certain disease or not (true/false).

...

Creating a matrix and accessing its properties

A matrix is a two-dimensional arrangement of vectors of the same type. Like vectors in R, the matrix is restricted to one data type. In this recipe, you will learn how to create a matrix, how to access its elements, and understand a few notes on matrix operations.

Getting ready

To get started with this recipe, you must have R installed on your computer. You also need to understand the structure of a matrix and various operations. There is no library required for this recipe, but if you are interested in advanced matrix algebra, then you might consider the See also section of this recipe. A matrix is considered as a two-dimensional grid where each cell is represented by a row and...

Creating a data frame and accessing its properties

A data frame in R is also a two-dimensional arrangement like a matrix, but it can contain a combination of data types in different columns. One column could be numeric, another column could be character. A data frame can be considered as a natural generalization of a matrix in R. In this recipe, you will learn how to create a data frame and how to access various columns and/or elements of it.

Getting ready

Since you have already learned to create a matrix, it will be relatively simple to understand the data frame. It is good to have an understanding of variables and datasets. Though the structure of a data frame is similar to a matrix, it has more information within it.

...

Creating an array and accessing its properties

An array is a way to organize data of the same type in more than two dimensions. An array could be of any dimension, and the data type must be the same in each of the array elements. A matrix is a special case of an array with only two dimensions. In this recipe, you will learn how to create an array and how to access its elements.

Getting ready

Suppose you are in a situation where you must store a series of matrices into a single R object and then perform analysis based on that; however, in this case, this is the perfect and efficient way to create an array. For example, you are in a situation to store four matrices of 2 x 2 order.

...

Creating a list from a combination of vector, matrix, and data frame

A list is the natural generalization of a data frame in R. A data frame is a rectangular arrangement of rows and columns where each of the columns must be of the same length. A list can contain a variety of heterogeneous objects with various lengths and data types. An array contains only one data type, whereas a list could contain heterogeneous data types of various lengths. In that sense, a list is also a natural generalization of an array. A list is a versatile R object, and it is important to know how it stores elements and how you can access it. In this recipe, you will learn how to create a list and access its elements.

Getting ready

Recall that you...

Converting a matrix to a data frame and a data frame to a matrix

A matrix is a two-dimensional arrangement of data with rows and columns where each row/column is of the same data type, either all numeric, all character, or all logical. Moreover, the number of elements in each column should be the same, and the number of elements in each row should also be the same.

A data frame is also a two-dimensional arrangement of data with rows and columns, but each column could be of very different types; for example, a data frame may contain both character and numeric columns. However, the number of elements in each column should be the same. Since both data structures share some common properties, they could be converted from one structure to another. In this recipe, you will learn to convert a matrix to a data frame and a data frame to a matrix.

...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Develop strategies to speed up your R code
  • Tackle programming problems and explore both functional and object-oriented programming techniques
  • Learn how to address the core problems of programming in R with the most popular R packages for common tasks

Description

R is a powerful tool for statistics, graphics, and statistical programming. It is used by tens of thousands of people daily to perform serious statistical analyses. It is a free, open source system whose implementation is the collective accomplishment of many intelligent, hard-working people. There are more than 2,000 available add-ons, and R is a serious rival to all commercial statistical packages. The objective of this book is to show how to work with different programming aspects of R. The emerging R developers and data science could have very good programming knowledge but might have limited understanding about R syntax and semantics. Our book will be a platform develop practical solution out of real world problem in scalable fashion and with very good understanding. You will work with various versions of R libraries that are essential for scalable data science solutions. You will learn to work with Input / Output issues when working with relatively larger dataset. At the end of this book readers will also learn how to work with databases from within R and also what and how meta programming helps in developing applications.

Who is this book for?

This book is for developers who would like to enhance the R programming skills. Basic knowledge of R programming is assumed.

What you will learn

  • • Install R and its various IDE for a given platform along with installing libraries from different repositories and version control
  • • Learn about basic data structures in R and how to work with them
  • • Write customized R functions and handle recursions, exceptions in R environments
  • • Create the data processing task as a step by step computer program and execute using dplyr
  • • Extract and process unstructured text data
  • • Interact with database management system to develop statistical applications
  • • Formulate and implement parallel processing in R

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 10, 2017
Length: 236 pages
Edition : 1st
Language : English
ISBN-13 : 9781787288775
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 10, 2017
Length: 236 pages
Edition : 1st
Language : English
ISBN-13 : 9781787288775
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
R$50 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
R$500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts
R$800 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 886.97
R Data Analysis Projects
R$306.99
R Programming By Example
R$306.99
Modern R Programming Cookbook
R$272.99
Total R$ 886.97 Stars icon
Banner background image

Table of Contents

9 Chapters
Installing and Configuring R and its Libraries Chevron down icon Chevron up icon
Data Structures in R Chevron down icon Chevron up icon
Writing Customized Functions Chevron down icon Chevron up icon
Conditional and Iterative Operations Chevron down icon Chevron up icon
R Objects and Classes Chevron down icon Chevron up icon
Querying, Filtering, and Summarizing Chevron down icon Chevron up icon
R for Text Processing Chevron down icon Chevron up icon
R and Databases Chevron down icon Chevron up icon
Parallel Processing in R Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.