# Programming in R

View:
Sorted by:

### How to Use Arithmetic Vector Operations in R

One set of arithmetic functions in R consists of functions in which the outcome is dependent on more than one value in the vector. Summing a vector with the

### The Benefits of Using R

Of the many attractive benefits of R programming language, a few are easy to recognize. It’s actively maintained, it has good connectivity to various types of data and other systems, and it’s versatile

### How to Perform Multiple Calculations with Vectors Using R

R is a vector-based language. You can think of a vectoras a row or column of numbers or text. The list of numbers {1,2,3,4,5}, for example, could be a vector. Unlike most other programming languages, R

### R Code Editor Options

R is many things: a programming language, a statistical processing environment, a way to solve problems, and a collection of helpful tools to make your life easier. The one thing that R is

### How to Navigate RGui

As part of the process of downloading and installing R, you get the standard graphical user interface (GUI), called RGui. RGui gives you some tools to manage your R environment — most important, a console

### How to Navigate RStudio

RStudio is a code editor and development environment with some very nice features that make code development in R easy and fun:

### How to Repeat Vectors in R

In R, you can combine a vector with itself if you want to repeat it, but if you want to repeat the values in a vector many times, using the c() function becomes a bit impractical. R makes life easier by

### How to Construct Vectors in R

A vector is the simplest type of data structure in R. The R manual defines a vector as “a single entity consisting of a collection of things.” A collection of numbers, for example, is a numeric vector

### How to Store and Calculate Values in R

Using R as a calculator is very interesting but perhaps not all that useful. A much more useful capability is storing values and then doing calculations on these stored values.

### How to Source a Script in R

When you want to tell R to perform several commands one after the other without waiting for additional instructions, you use the source()function. R users refer to this process as

### How to Navigate the Workspace in R

The workspace refers to all the variables and functions (collectively called objects) that you create during an R session, as well as any packages that are loaded.

### How to Vectorize Your Functions in R

Vectorized functions are a very useful feature of R, but programmers who are used to other languages often have trouble with this concept at first. A vectorized

### How to Put Arguments in Your R Functions

Most functions in R have arguments that give them more information about exactly what you want them to do. If you use print("Hello world!"), you give the argument

### How to Save the History of Your Work in R

By default, R keeps track of all the commands you use in a session. This tracking can come in handy if you need to reuse a command you used earlier or want to keep track of the work you did before. These

### How to Successfully Follow Naming Conventions in R

R is very liberal when it comes to names for objects and functions. This freedom is a great blessing and a great burden at the same time. Nobody is obliged to follow strict rules, so everybody who programs

### How to Get Values out of Vectors in R

Vectors would be pretty impractical if you couldn’t look up and manipulate individual values. You can perform these tasks easily by using R’s advanced, powerful indexing system.

### How to Select Naming Styles in R

If you have experience in programming, you’ve probably heard of camel case, before. It’s a way of giving longer names to objects and functions. You capitalize every first letter of a word that is part

### How to Structure Your Code in R

Names aren’t the only things that can influence the readability of your R code. When you start nesting functions or perform complex calculations, your code can turn into a big mess of text and symbols

You install a package in R with the function — wait for it — install.packages(). Who could’ve guessed? So, to install the fortunes package, for example, you simply give the name of the package as a string

### How to Do Basic Arithmetic in R

Since R is statistics platform, it has a rather complete set of arithmetic operators, so you can use R as a fancy calculator if the need arises.

### How to Round Off Numbers in R

Although R can calculate accurately to up to 16 digits, you don’t always want to use that many digits. In this case, you can use a couple functions in R to round numbers. To round a number to two digits

### How to Use Mathematical Functions in R

In R, of course, you want to use more than just basic operators. R comes with a whole set of mathematical functions. R naturally contains a whole set of functions that you’d find on a technical calculator

### How to Change Values in a Vector in R

Changing values in a vector in R is actually pretty simple. To illustrate, let’s assume that you created two vectors containing the number of baskets that Granny and Geraldine made in six basketball games

### How to Use Trigonometric Functions in R

All trigonometric functions are available in R: the sine, cosine, and tangent functions and their inverse functions. You can find them on the Help page you reach by typing

### How R Calculates Infinite, Undefined, and Missing Values

Luckily, R can deal with data anomalies that confound some other statistical platforms. For instance, in some cases, you don’t have real values to calculate with. In most real-life data sets, in fact,