{"id":75387,"date":"2020-01-11T15:27:16","date_gmt":"2020-01-11T09:57:16","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=75387"},"modified":"2020-01-11T15:27:16","modified_gmt":"2020-01-11T09:57:16","slug":"r-arrays","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/","title":{"rendered":"R Arrays &#8211; A Comprehensive Guide to Array with Examples"},"content":{"rendered":"<p><strong>This TechVidvan tutorial is designed to help R programming beginner to get a clear understanding of how to easily work with R arrays.\u00a0<\/strong><\/p>\n<p>Arrays are <strong>multi-dimensional<\/strong> data structures in R. This means that they can have any number of dimensions. They are vectors with two or more dimensions to them. Matrices are a special case of 2-D arrays.<\/p>\n<p>In this tutorial, we will explore the concept of arrays in R programming. We will learn to create arrays, name rows, columns, and other dimensions. We will then look at accessing their elements and modifying them.<\/p>\n<p>Finally, we will look at how different operations on arrays work in the R programming language.<\/p>\n<p>So, are you excited?<\/p>\n<h2>What are arrays in R?<\/h2>\n<p>R arrays are data objects that store data in more than two dimensions. Arrays are <strong>homogeneous<\/strong> in nature. This means that they can store values of a <strong>single basic data type only.<\/strong> They store the data in the form of <strong>layered matrices<\/strong>. Let us take a look at different ways of creating an array.<\/p>\n<p>But before learning how to create an array in R, first look at the syntax of the array function.<\/p>\n<h3>Array function syntax<\/h3>\n<p>The syntax of the <strong><code>array()<\/code><\/strong>function is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Array_name = array(data,dim = c(row_size,column_size,matrices), dimnames = list(row_names,column_names,matrices_names))<\/pre>\n<p>Where <strong><code>data<\/code><\/strong> is a vector that provides the values to fill the array,<\/p>\n<p><strong><code>dim<\/code><\/strong> is a vector that tells the dimensions of the array,<\/p>\n<p><strong><code>row_size<\/code><\/strong> is the number of rows in the array,<\/p>\n<p><strong><code>column_size<\/code><\/strong> is the number of columns in the array,<\/p>\n<p><strong><code>matrices<\/code><\/strong> denotes the number of matrices in the array,<\/p>\n<p><strong><code>dimnames<\/code><\/strong> is a list of names for the dimensions of the array,<\/p>\n<p><strong><code>row_names<\/code><\/strong> is a vector with the names for all the rows,<\/p>\n<p><strong><code>column_names<\/code><\/strong> is a vector with the names for all the columns,<\/p>\n<p><strong><code>matrices_names<\/code><\/strong> is a vector with the names for all the matrices in the array.<\/p>\n<h3>Creating R arrays<\/h3>\n<p>There are many ways to create R arrays. We can use the <strong><code>array()<\/code><\/strong> function to create an array.<\/p>\n<p>For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; arr1 &lt;- array(c(1:18),dim=c(2,3,3))\n&gt; arr1<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/array-in-r-creating-array-array-arr1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75392\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/array-in-r-creating-array-array-arr1.png\" alt=\"creating R array array() arr1\" width=\"1299\" height=\"733\" \/><\/a><\/strong><\/p>\n<p>We can also create an array by <strong>changing the dimensions<\/strong> of a vector. For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; vec_to_arr &lt;- c(1,2,3,4,5,6,7,8)\n&gt; dim(vec_to_arr) &lt;- c(2,2,2)\n&gt; vec_to_arr<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-creating-array-vec_to_arr.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75393\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-creating-array-vec_to_arr.png\" alt=\"creating R array vec_to_arr\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h3>Naming the dimensions of R arrays<\/h3>\n<p>We can name the rows, columns, and matrices of an array during its creation by using the <strong><code>dimnames<\/code><\/strong> attribute of the <strong><code>array()<\/code><\/strong> function. For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; rnames &lt;- c(\"r1\",\"r2\",\"r3\")\n&gt; cnames &lt;- c(\"c1\",\"c2\",\"c3\")\n&gt; mnames &lt;- c(\"m1\",\"m2\",\"m3\")\n&gt; named_array &lt;- array(c(1:27),dim=c(3,3,3),dimnames= list(rnames,cnames,mnames))\n&gt; named_array<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-naming-dimensions-during-creation.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75394\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-naming-dimensions-during-creation.png\" alt=\"naming dimensions during creation - R arrays\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<p>We can use the <strong><code>dimnames()<\/code><\/strong>function to name the dimensions and to change their names after an array\u2019s creation. For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; named_array2 &lt;- array(c(1:18),c(3,3,2))\n&gt; mnames2 &lt;- c(\"m1\",\"m2\")\n&gt; dimnames(named_array2) &lt;- list(rnames,cnames,mnames2)\n&gt; named_array2<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<h3><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-naming-dimensions-after-creation-using-dimnames.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75395\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-naming-dimensions-after-creation-using-dimnames.png\" alt=\"naming dimensions after creation using dimnames- arrays in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/h3>\n<h3>Indexing R array<\/h3>\n<p>We can access the elements of an array by using the<strong> square brackets<\/strong> to denote an index. We can use four types of indices for this, which are positive integers, negative integers, logical values or characters.<\/p>\n<h4>Using positive integers<\/h4>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; named_array[2,1,3] #second row, first column and third matrix of named_array<\/pre>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; named_array[c(1,2),c(2,3),c(1,2)] #first and second row, second and third column of first and second matrices<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<h4><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-positive-integer-indexing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75396\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-positive-integer-indexing.png\" alt=\"positive integer indexing arrays in r \" width=\"1299\" height=\"741\" \/><\/a><\/strong>Using negative integers<\/h4>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; named_array[-1,-3,-2] #remove first row, third column and second matrix of named_array<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<h4><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-negative-integer-indexing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75397\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-negative-integer-indexing.png\" alt=\"negative integer indexing - arrays in r \" width=\"1299\" height=\"741\" \/><\/a><\/strong>Using logical vectors<\/h4>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; named_array[c(T,F,T),c(F,T,T),c(T,T,F)] #first and third row, second and third column of first and second matrix of named_array<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-logical-indexing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75398\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-logical-indexing.png\" alt=\"logical indexing - arrays in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<p>Logical index vectors recycle, in case they are shorter than the array dimensions. For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;named_array[c(T,F),c(F,T),c(T,T,F),drop=FALSE]<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-logical-indexing-recycling.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75399\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-logical-indexing-recycling.png\" alt=\"logical indexing recycling - R arrays\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<p><strong>Note:<\/strong> If we select a single entry of any dimension of an array, the result will be a matrix. To avoid that, we use drop=<strong><code>FALSE<\/code><\/strong> argument.<\/p>\n<h4>Using character vectors<\/h4>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; named_array[c(\"r1\",\"r3\"),c(\"c2\",\"c3\"),c(\"m1\",\"m2\")]<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-character-indexing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75400\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-character-indexing.png\" alt=\"character indexing in R arrays\" width=\"1299\" height=\"741\" \/><\/a><\/p>\n<h3>Modifying R array<\/h3>\n<p>We can use the indexing techniques to access elements or parts of an array. Then we can use <strong>re-assignment<\/strong> to change their values. For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; named_array[1,,1] &lt;- c(4,4,4)\n&gt; named_array<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-modifying-elements.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75401\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-modifying-elements.png\" alt=\"modifying elements array in r \" width=\"1299\" height=\"730\" \/><\/a><\/strong><\/p>\n<p>We can also use the <strong><code>dim()<\/code><\/strong> function to change the dimensions of an array. For example:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; dim(arr1) &lt;- c(3,3,2)\n&gt; arr1<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<h3><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-modify-dim.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75402\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-modify-dim.png\" alt=\"modify dim() - arrays in R\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/h3>\n<h3>R Array arithmetic<\/h3>\n<p>In <a href=\"https:\/\/www.r-project.org\/\">R<\/a>, the basic operations of addition, subtraction, multiplication, and division work element-wise. We need to ensure that the arrays are of the proper size and valid according to matrix arithmetic.<\/p>\n<p>For example, the number of rows of the first matrix and the number of columns of the second matrix should be the same for multiplication.<\/p>\n<h4>1. Addition<\/h4>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; test_arr1 &lt;- array(c(1:8),c(2,2,2))\n&gt; test_arr2 &lt;- array(c(9:16),c(2,2,2))\n&gt; arr_add &lt;- test_arr1+test_arr2\n&gt; arr_add<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-array-addition.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75403\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-array-addition.png\" alt=\"R array addition\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h4>2. Subtraction<\/h4>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; arr_sub &lt;- test_arr2-test_arr1\n&gt; arr_sub<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<h4><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-array-subtraction.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75404\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-array-subtraction.png\" alt=\"R arrays subtraction\" width=\"1299\" height=\"741\" \/><\/a><\/strong>3. Multiplication<\/h4>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; arr_mul &lt;- test_arr1*test_arr2\n&gt; arr_mul<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<h4><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-array-multiplication.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75405\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-array-multiplication.png\" alt=\"R array multiplication\" width=\"1299\" height=\"741\" \/><\/a><\/strong>4. Division<\/h4>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; arr_div &lt;- test_arr2\/test_arr1\n&gt; arr_div<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-array-division.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75406\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-array-division.png\" alt=\"R array division\" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h4>5. Power operator<\/h4>\n<p>The power operator<strong><code>^<\/code><\/strong>works on R arrays in the same fashion that is element-wise.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; arr_pow &lt;- test_arr1^2\n&gt; arr_pow<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-power-operator.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75407\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-power-operator.png\" alt=\"power operator - arrays in r \" width=\"1299\" height=\"741\" \/><\/a><\/strong><\/p>\n<h4>6. The apply() Function<\/h4>\n<p>We can also perform operations on array elements with the <strong><code>apply()<\/code><\/strong> function. The apply function performs a given function on all columns or all rows of an array or matrix.<\/p>\n<p>For example, the following code gives the sums of all the columns of <strong><code>test_arr1<\/code><\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; test_arr1<\/pre>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; col_sum &lt;- apply(test_arr1,2,sum)\n&gt; col_sum<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<h2><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-apply-function.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75408\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/arrays-in-r-apply-function.png\" alt=\"apply() function - arrays in r\" width=\"1299\" height=\"741\" \/><\/a><\/strong>Summary<\/h2>\n<p>In this tutorial, we learned about the arrays in R programming. We learned about their creation, modification, and manipulation. We saw how to access their elements. Finally, we looked at a few basic mathematical operations on arrays.<\/p>\n<p>R Arrays are special vectors with multiple dimensions to them. They store multidimensional rectangular data.<\/p>\n<p>Now you must be realizing how important R vector is, take a tour to <strong><a href=\"https:\/\/techvidvan.com\/tutorials\/r-vector\/\">R vectors<\/a> <\/strong>and master the concept.<\/p>\n<p>The above article should give you a clear understanding of arrays in the R programming language.<\/p>\n<p>Confusion in R array examples? Ask TechVidvan in the comment section.<\/p>\n<p>Keep learning!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This TechVidvan tutorial is designed to help R programming beginner to get a clear understanding of how to easily work with R arrays.\u00a0 Arrays are multi-dimensional data structures in R. This means that they&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":75412,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1020],"tags":[1352,1353,1354,1355,1356,1357,1358,1359],"class_list":["post-75387","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r","tag-3-dimensional-array-in-r","tag-3d-array-r","tag-array-function-in-r","tag-array-in-r-programming","tag-arrays-in-r","tag-define-array-in-r","tag-index-r-array","tag-r-arrays"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>R Arrays - A Comprehensive Guide to Array with Examples - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn what R array is, how to create array in R and how you can do arithmetic operations on R array? Learn everything about it with examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/r-arrays\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"R Arrays - A Comprehensive Guide to Array with Examples - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn what R array is, how to create array in R and how you can do arithmetic operations on R array? Learn everything about it with examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/r-arrays\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-11T09:57:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/arrays-in-R.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"R Arrays - A Comprehensive Guide to Array with Examples - TechVidvan","description":"Learn what R array is, how to create array in R and how you can do arithmetic operations on R array? Learn everything about it with examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/","og_locale":"en_US","og_type":"article","og_title":"R Arrays - A Comprehensive Guide to Array with Examples - TechVidvan","og_description":"Learn what R array is, how to create array in R and how you can do arithmetic operations on R array? Learn everything about it with examples.","og_url":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-01-11T09:57:16+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/arrays-in-R.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"R Arrays &#8211; A Comprehensive Guide to Array with Examples","datePublished":"2020-01-11T09:57:16+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/"},"wordCount":787,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/arrays-in-R.jpg","keywords":["3 dimensional array in R","3D array R","array function in R","array in R programming","Arrays in R","define array in R","index R array","R arrays"],"articleSection":["R Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/r-arrays\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/","url":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/","name":"R Arrays - A Comprehensive Guide to Array with Examples - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/arrays-in-R.jpg","datePublished":"2020-01-11T09:57:16+00:00","description":"Learn what R array is, how to create array in R and how you can do arithmetic operations on R array? Learn everything about it with examples.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/r-arrays\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/arrays-in-R.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/arrays-in-R.jpg","width":802,"height":420,"caption":"R array"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/r-arrays\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"R Arrays &#8211; A Comprehensive Guide to Array with Examples"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/75387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=75387"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/75387\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/75412"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=75387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=75387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=75387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}