Hits: 9 R While Loop A while loop is used when you want to perform a task indefinitely, until a particular condition is met. It’s a condition-controlled loop. Syntax Here’s the syntax of the while statement: Basic Examples Any non-zero value or nonempty container is considered TRUE; whereas Zero, None, and empty container is considered FALSE. # Iterate until …

Hits: 31 R if else elseif Statement Often, you need to execute some statements only when some condition is met. You can use following conditional statements in your code to do this. if Statement: use it to execute a block of code, if a specified condition is true else Statement: use it to execute a block of …

Hits: 2 R Factor In real-world problems, you often encounter data that can be classified in categories. For example, suppose a survey was conducted of a group of seven individuals, who were asked to identify their hair color and gender. The result might appear as follows: Name Hair color Gender Amy Blonde Female Bob Black …

Hits: 16 R Data Frame Suppose you want to store the names of your employees, their age and addresses all in one dataset. The first thing that readily comes to mind is Matrix. But you can’t combine all this data in one matrix without converting it to character data. So, you need a new data structure …

Hits: 1 R Matrix A matrix is a collection of elements, all the same type, arranged in a two-dimensional layout. In a nutshell, a matrix is just a vector that has two dimensions. When using R, you will frequently encounter the four basic matrix types viz. logical, character, integer and double (often called numeric). Create a Matrix …

Hits: 2 R List Vectors and matrices are incredibly useful data structure in R, but they have one distinct limitation: they can store only one type of data. Lists, however, can store multiple types of values at once. A list can contain a numeric matrix, a logical vector, a character string, a factor object and even another list. …

Hits: 6 R Operators Operators are used to perform operations on values and variables. The R operators are classified into six different categories: Arithmetic operators Comparison operators Logical operators Element-wise Logical operators Membership operators Assignment operators Arithmetic Operators Arithmetic operators are used to perform simple mathematical operations on numeric values and vectors. Operator Meaning …

Hits: 8 R Introduction R is a powerful programming language for statistical computing and data analysis. It was developed in the early 1990s by Ross Ihaka and Robert Gentleman, and released in 2000. R is still maintained by the R Core Team. Who uses R? Here’s a list of some top-tier companies that you know …