{"id":75016,"date":"2020-01-02T15:15:35","date_gmt":"2020-01-02T09:45:35","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=75016"},"modified":"2020-01-02T15:15:35","modified_gmt":"2020-01-02T09:45:35","slug":"r-data-structures","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/","title":{"rendered":"6 Inbuilt Data Structures in R with practical examples"},"content":{"rendered":"<p>In R, most of the time you will be dealing with collections of data and not singular elements. We hold collections of data in data structures.<\/p>\n<p>Data structures are objects in R that provide a method to arrange data in the desired format.<\/p>\n<p>In this article, we will take a look at the data structures in R. We will learn what they are, and what are their uses. We will also explore a few features and functions of these structures.<\/p>\n<p>Let&#8217;s start with understanding the basics of data structures.<\/p>\n<h2>Introduction to Data Structures in R<\/h2>\n<p>R has <strong>six types<\/strong> of basic data structures. We can organize these data structures according to their <strong>dimensions<\/strong>(1d, 2d, nd). We can also classify them as <strong>homogeneous<\/strong> or <strong>heterogeneous <\/strong>(can their contents be of different types or not).<\/p>\n<p>Homogeneous data structures are ones that can only store a single type of data (numeric, integer, character, etc.).<\/p>\n<p>Heterogeneous data structures are ones that can store more than one type of data at the same time.<\/p>\n<p>R does not have 0 dimensional or scalar type. Variables containing single values are vectors of length 1.<\/p>\n<p>We have discussed <strong><a href=\"https:\/\/techvidvan.com\/tutorials\/r-data-types\/\">every concept of R data types<\/a><\/strong> in our previous article, now we are going to understand R data structures in detail.<\/p>\n<p>R has the following basic data structures:<\/p>\n<ol>\n<li>Vector<\/li>\n<li>List<\/li>\n<li>Matrix<\/li>\n<li>Data frame<\/li>\n<li>Array<\/li>\n<li>Factor<\/li>\n<\/ol>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/R-data-strucutres.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75095\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/R-data-strucutres.jpg\" alt=\"data structures in R\" width=\"802\" height=\"420\" \/><\/a><\/p>\n<p>So, let\u2019s not wait anymore and get to it!<\/p>\n<h3>1. Vectors<\/h3>\n<p>Vectors are <strong>single-dimensional, homogeneous<\/strong> data structures. To create a vector, use the c() function.<\/p>\n<p><strong>For example<\/strong>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; vec &lt;- c(1,2,3) # creates a vector named vec\n&gt; vec<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<div class=\"code-output\">[1] 1 2 3<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-vectors-vec1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75054\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-vectors-vec1.png\" alt=\"vectors data structures in R \" width=\"1300\" height=\"744\" \/><\/a><\/p>\n<p>The assign() function is another way to create a vector.<\/p>\n<p><strong>For example<\/strong>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; assign(\"vec2\", c(4,5,6))\n&gt; vec2<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<div class=\"code-output\">[1] 4 5 6<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-vectors-vec2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75055\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-vectors-vec2.png\" alt=\"R data structures vectors\" width=\"1300\" height=\"744\" \/><\/a><\/p>\n<p>Vectors can hold values of a single data type. Thus, they can be numeric, logical, character, integer or complex vectors.<\/p>\n<p><strong>For example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; numeric_vec &lt;- c(1,2,3,4,5)\n&gt; integer_vec &lt;- c(1L,2L,3L,4L,5L)\n&gt; logical_vec &lt;- c(TRUE, TRUE, FALSE, FALSE, FALSE)\n&gt; complex_vec &lt;- c(12+2i, 3i, 4+1i, 5+12i, 6i)\n&gt; character_vec &lt;- c(\"techvidvan\", \"this\", \"is\", \"a\", \"character vector\")\n&gt; numeric_vec\n&gt; integer_vec\n&gt; logical_vec\n&gt; complex_vec\n&gt; character_vec<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<div class=\"code-output\">\n<p>[1] 1 2 3 4 5<\/p>\n<p>[1] 1 2 3 4 5<\/p>\n<p>[1] TRUE FALSE TRUE FALSE FALSE<\/p>\n<p>[1] 12+ 2i 0+ 3i 4+ 1i 5+12i 0+ 6i<\/p>\n<p>[1] &#8220;techvidvan&#8221; &#8220;this&#8221;<br \/>\n[3] &#8220;is&#8221; &#8220;a&#8221;<br \/>\n[5] &#8220;character vector&#8221;<\/p>\n<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-vector-types3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75056\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-vector-types3.png\" alt=\"vector types-data structures in R\" width=\"1300\" height=\"744\" \/><\/a><\/p>\n<p>The above code will create the following vectors with corresponding values and types.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-vector-types4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75057\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-vector-types4.png\" alt=\"vector types data structures in R\" width=\"518\" height=\"281\" \/><\/a><\/p>\n<p><strong>Note:<\/strong> Technically, we can store different types of data but R converts the values to maintain the vector\u2019s homogeneous nature. This is called <strong>Coercion<\/strong>.<\/p>\n<p>If you want to implement this example on your own, then I would recommend you to <em><strong><a href=\"https:\/\/techvidvan.com\/tutorials\/install-r\/\">install R<\/a><\/strong><\/em> by our step by step R tutorial.<\/p>\n<h3>2. Lists<\/h3>\n<p>Lists are <strong>heterogeneous<\/strong> data structures. They are very similar to vectors except they can store data of different types. To create a list, we use the list() function.<\/p>\n<p><strong>For example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; test_list &lt;- list(1, \"hello\", c(2,3,1), FALSE, 3+4i, 6L)\n&gt; test_list<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<div class=\"code-output\">\n<p>[[1]]<br \/>\n[1] 1<\/p>\n<p>[[2]]<br \/>\n[1] &#8220;hello&#8221;<\/p>\n<p>[[3]]<br \/>\n[1] 2 3 1<\/p>\n<p>[[4]]<br \/>\n[1] FALSE<\/p>\n<p>[[5]]<br \/>\n[1] 3+4i<\/p>\n<p>[[6]]<br \/>\n[1] 6<\/p>\n<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/R-data-structures-lists-test5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75058\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/R-data-structures-lists-test5.png\" alt=\"lists test-data structures in R\" width=\"1300\" height=\"744\" \/><\/a><\/p>\n<p>Lists are often called \u201c<strong>recursive vectors<\/strong>\u201d as you can store a list inside another list.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; test_list2&lt;-list(list(1,\"a\",TRUE), list(\"b\",45L,\"c\"), list(1,2))\n&gt; str(test_list2) #shows the structure of an object<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<div class=\"code-output\">List of 3<br \/>\n$ :List of 3<br \/>\n..$ : num 1<br \/>\n..$ : chr &#8220;a&#8221;<br \/>\n..$ : logi TRUE<br \/>\n$ :List of 3<br \/>\n..$ : chr &#8220;b&#8221;<br \/>\n..$ : int 45<br \/>\n..$ : chr &#8220;c&#8221;<br \/>\n$ :List of 2<br \/>\n..$ : num 1<br \/>\n..$ : num 2<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-lists-test6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75059\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-lists-test6.png\" alt=\"R data structures lists test\" width=\"1300\" height=\"744\" \/><\/a><\/p>\n<p><strong>Note: <\/strong>If the c() function has a list as an argument, the result will be a list. Other values inside the c() function will be coerced into lists themselves.<\/p>\n<h3>3. Matrix<\/h3>\n<p>Matrices are<strong> two-dimensional, homogeneous<\/strong> data structures. This means that all values in a matrix have to be of the same type. Coercion takes place if there is more than one data type. They have rows and columns.<\/p>\n<p>By default, matrices are in <strong>column-wise<\/strong> order. The basic syntax to create a matrix is:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;matrix( data, nrow, ncol, byrow, dimnames)<\/pre>\n<p>Where <strong>data<\/strong> is the input values in the matrix given as a vector,<\/p>\n<p><strong>nrow<\/strong> is the number of rows,<\/p>\n<p><strong>ncol<\/strong> is the number of columns,<\/p>\n<p><strong>byrow<\/strong> is a logical which tells the function to arrange the matrix row-wise, by default it is set to FALSE,<\/p>\n<p><strong>dimnames<\/strong> is a list of the names of the rows\/columns created.<\/p>\n<p>The following code will create a matrix with 3 rows and values 1 to 9 in a column-wise order.<\/p>\n<p><strong>For example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; test_matrix1 &lt;- matrix(c(1:9), ncol = 3)\n&gt; test_matrix1<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<div class=\"code-output\">\u00a0 \u00a0 \u00a0 \u00a0[,1] [,2] [,3]<br \/>\n[1,]\u00a0 \u00a01\u00a0 \u00a0 4\u00a0 \u00a0 \u00a07<br \/>\n[2,]\u00a0 \u00a02\u00a0 \u00a0 5\u00a0 \u00a0 \u00a08<br \/>\n[3,]\u00a0 \u00a03\u00a0 \u00a0 6\u00a0 \u00a0 \u00a09<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/R-data-structures-matrices-matrix7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75060\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/R-data-structures-matrices-matrix7.png\" alt=\"data structures in R matrices matrix\" width=\"1300\" height=\"741\" \/><\/a><\/p>\n<p>An example of a matrix with row-names and column-names:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; rownames &lt;- c(\"row1\", \"row2\", \"row3\")\n&gt; colnames &lt;- c(\"col1\", \"col2\", \"col3\")\n&gt; test_matrix2 &lt;- matrix(c(1:9), ncol = 3, dimnames = list(rownames, colnames))\n&gt; test_matrix2<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<div class=\"code-output\">\u00a0 \u00a0 \u00a0 \u00a0col1 col2 col3<br \/>\nrow1\u00a0 \u00a01\u00a0 \u00a0 \u00a04\u00a0 \u00a0 \u00a0 \u00a07<br \/>\nrow2\u00a0 \u00a02\u00a0 \u00a0 \u00a05\u00a0 \u00a0 \u00a0 \u00a08<br \/>\nrow3\u00a0 \u00a03\u00a0 \u00a0 \u00a06\u00a0 \u00a0 \u00a0 \u00a09<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-matrices-matrix8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75061\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/data-structures-matrices-matrix8.png\" alt=\"data structures in R matrices matrix\" width=\"1300\" height=\"744\" \/><\/a><\/p>\n<h3>4. Data Frames<\/h3>\n<p>Data frames are <strong>two-dimensional, heterogeneous<\/strong> data structures. They are lists of vectors of equal lengths. Data frames have the following constraints placed upon them:<\/p>\n<ol>\n<li>A data-frame <strong>must have column-names<\/strong> and each row should have a <strong>unique name<\/strong>.<\/li>\n<li>Each column should have the <strong>same number<\/strong> of items.<\/li>\n<li>Each item in a single column should be of the <strong>same type<\/strong>.<\/li>\n<li>Different columns can have different data types.<\/li>\n<\/ol>\n<p>To create a data frame, use the data.frames() function.<\/p>\n<p><strong>For example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; student_id &lt;- c(1:5)\n&gt; student_name &lt;- c(\"raj\", \"jacob\", \"iqbal\", \"shawn\", \"hitesh\")\n&gt; student_rank &lt;- c(\"third\", \"fifth\", \"second\", \"fourth\", \"first\")\n&gt; student.data &lt;- data.frame(student_id , student_name, student_rank)\n&gt; student.data<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<div class=\"code-output\">\u00a0 \u00a0 student_id\u00a0 \u00a0 \u00a0student_name\u00a0 \u00a0 student_rank<br \/>\n1\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a01\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 raj\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0third<br \/>\n2\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a02\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 jacob\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0fifth<br \/>\n3\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a03\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 iqbal\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 second<br \/>\n4\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a04\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 shawn\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 fourth<br \/>\n5\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a05\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 hitesh\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0first<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/R-data-structures-data-frames-student9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75062\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/R-data-structures-data-frames-student9.png\" alt=\"data frames student-data structures in R\" width=\"1299\" height=\"742\" \/><\/a><\/p>\n<h3>5. Arrays<\/h3>\n<p>Arrays are<strong> three dimensional, homogeneous<\/strong> data structures. They are collections of matrices stacked one on top of the other in layers.<\/p>\n<p>You can create an array using the array() function. The following is the syntax of it:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Array_name = array(data,dim,dimnames)<\/pre>\n<p>Where <strong>array_name<\/strong> is the name of the array,<\/p>\n<p><strong>data<\/strong> is the data that is filled inside the array,<\/p>\n<p><strong>dim<\/strong> is a vector containing the dimensions of the array,<\/p>\n<p>and <strong>dimnames<\/strong> is a list containing the names of the rows, columns, and matrices inside the <a href=\"https:\/\/cran.r-project.org\/doc\/manuals\/r-release\/R-intro.html#Arrays\">array<\/a>.<\/p>\n<p>Here is an <strong>example<\/strong> of the array() function:<\/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<div class=\"code-output\">, , 1[,1] [,2] [,3]<br \/>\n[1,] 1 3 5<br \/>\n[2,] 2 4 6, , 2[,1] [,2] [,3]<br \/>\n[1,] 7 9 11<br \/>\n[2,] 8 10 12, , 3[,1] [,2] [,3]<br \/>\n[1,] 13 15 17<br \/>\n[2,] 14 16 18<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/array-in-r-creating-array-Array10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75063\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/array-in-r-creating-array-Array10.png\" alt=\"array in r programming\" width=\"1300\" height=\"741\" \/><\/a><\/p>\n<h3>6. Factors<\/h3>\n<p>Factors are vectors that can only store predefined values. They are useful for storing <strong>categorical data<\/strong>. Factors have two attributes:<\/p>\n<ul>\n<li><strong>Class<\/strong> &#8211; which has a value of \u201cfactor\u201d, it makes it behave differently than a normal vector.<\/li>\n<li><strong>Levels<\/strong> &#8211; which is the set of allowed values<\/li>\n<\/ul>\n<p>You can create a factor using the factor() function.<\/p>\n<p><strong>For example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; fac &lt;- factor(c(\"a\", \"b\", \"a\", \"b\", \"b\"))\n&gt; fac<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<div class=\"code-output\">[1] a b a b b<br \/>\nLevels: a b<\/div>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/R-data-structures-factors11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-75064\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/R-data-structures-factors11.png\" alt=\"R data structures factors\" width=\"1300\" height=\"741\" \/><\/a><\/p>\n<p>Factors can store both strings and integers. They are useful to categorize unique values in columns like \u201cTRUE\u201d or \u201cFALSE\u201d, or \u201cMALE\u201d or \u201cFEMALE\u201d, etc..<\/p>\n<h2>Summary<\/h2>\n<p>In this tutorial, we looked at the basic data structures available in R. R has many complex data structures. We can make them using these basic structures in different combinations and formations.<\/p>\n<p>In R, almost every calculation is done on structures containing many values. Calculations on singular values are very rare.<\/p>\n<p>Thus, these data structures are very important building blocks in the R programming language.<\/p>\n<p>Still, any confusion regarding data structures in R?<\/p>\n<p>Ask <strong>TechVidvan<\/strong> experts in the comment section below!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In R, most of the time you will be dealing with collections of data and not singular elements. We hold collections of data in data structures. Data structures are objects in R that provide&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":75095,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1020],"tags":[1246,1247,1248,1249,1250,1251,1252,1253,1254],"class_list":["post-75016","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r","tag-data-structures-in-r","tag-data-structures-in-r-programming","tag-r-array","tag-r-data-frame","tag-r-data-structures","tag-r-factor","tag-r-list","tag-r-matrix","tag-r-vector"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>6 Inbuilt Data Structures in R with practical examples - TechVidvan<\/title>\n<meta name=\"description\" content=\"R data structures - Get a clear understanding of all the six basic data structures in R namely vector, list, matrix, array, factor, data frame.\" \/>\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-data-structures\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"6 Inbuilt Data Structures in R with practical examples - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"R data structures - Get a clear understanding of all the six basic data structures in R namely vector, list, matrix, array, factor, data frame.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/\" \/>\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-02T09:45:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/R-data-strucutres.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":"6 Inbuilt Data Structures in R with practical examples - TechVidvan","description":"R data structures - Get a clear understanding of all the six basic data structures in R namely vector, list, matrix, array, factor, data frame.","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-data-structures\/","og_locale":"en_US","og_type":"article","og_title":"6 Inbuilt Data Structures in R with practical examples - TechVidvan","og_description":"R data structures - Get a clear understanding of all the six basic data structures in R namely vector, list, matrix, array, factor, data frame.","og_url":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-01-02T09:45:35+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/R-data-strucutres.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-data-structures\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"6 Inbuilt Data Structures in R with practical examples","datePublished":"2020-01-02T09:45:35+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/"},"wordCount":985,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/R-data-strucutres.jpg","keywords":["data structures in R","Data Structures in R Programming","R array","R Data Frame","R data structures","R Factor","r list","R matrix","R Vector"],"articleSection":["R Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/r-data-structures\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/","url":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/","name":"6 Inbuilt Data Structures in R with practical examples - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/R-data-strucutres.jpg","datePublished":"2020-01-02T09:45:35+00:00","description":"R data structures - Get a clear understanding of all the six basic data structures in R namely vector, list, matrix, array, factor, data frame.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/r-data-structures\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/R-data-strucutres.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/R-data-strucutres.jpg","width":802,"height":420,"caption":"data structures in R"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/r-data-structures\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"6 Inbuilt Data Structures in R with practical 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\/75016","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=75016"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/75016\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/75095"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=75016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=75016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=75016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}