Book Image

Modern R Programming Cookbook

By : Jaynal Abedin
Book Image

Modern R Programming Cookbook

By: Jaynal Abedin

Overview of this book

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.
Table of Contents (10 chapters)

Writing your first function in R

A function in R is a set of instructions for a certain task to complete. The function could take any input you define, or it could work without any input. In this recipe, you will learn how to write a function and you will learn about the components of a function.

Getting ready

Let’s say you want to calculate the ratio of the standard deviation and mean of a given vector of five numbers. The input values are (3, 7, 2, 6, 9). To give these five values as an input to a function, you need to create a vector that contains these numbers as follows:

    V1 <- c(3, 7, 2, 6, 9)

How to do it…...