Return to site

Alternative to tidy plates

broken image
broken image

The value stored in this ‘i’ variable changes as the function ‘loops through’ the vector.įurthermore, the result calculated within the curly brackets must be ‘printed’ out the console using the print() function.

broken image

The job to perform on each dataset is given in curly brackets.Ī single value in the input vector is referred to as i. A vector of values for which the repetitive function is performed, is given within standard brackets. The for loop in R has a special structure requiring both standard () and curly brackets. This is a staple of computer programming in any language, and allows us to perform the same task on any number of input values or datasets, known as ‘looping through inputs’. Before embarking on this task, let’s get familiar with a little function called the ‘ for loop’.