R Tutorials
R Data Structures
R Graphics
R Statistics
R Examples
Compared to matrix, the same members can have more than two sizes.
We can use the array() function to create a list, and a dim parameter to specify a size:
In the example above we create a list of numbers 1 to 24.
How does dim = c (4,3,2) work?
The first and second numbers in parentheses determine the number of rows and columns.
The last number in parentheses indicates how many values we want.
Note: Lists can contain only one type of data.
You can access the elements of the same members by referring to the index area. You can use [] brackets to access the desired elements in the list:
The syntax is as follows: list [row location, column location, matrix level]
You can also access the entire row or column from the matrix in the list, using the function c():
The comma (,) before c () indicates that we want to reach the column.
The comma (,) after c () indicates that we want to reach the line.
To find out if something is listed, use %in% operator:
Check if the value "2" is present in the array:
Use the dim() function to find the number of rows and columns in an order:
Use the length() function to find the size of the same member:
You can access the program properties via for loop: