OneBite.Dev - Coding blog in a bite size

count array's length in R

Code snippet on how to count array's length in R

  length(x) 

This code is used to find out the length of an array in the R programming language. The length() function takes in an array, here we’ll refer to it as ‘x’, and returns the length of that array. An array is simply a collection of related items all stored in a single variable. The number of elements in the array, or the length, is an indication of how much data the array holds. This function returns the length of the array so that it can be used in other calculations. For example, if the length of the array is 5, that means it holds 5 elements and can be used to do further processing.

r