

{"id":4837,"date":"2017-12-01T11:26:57","date_gmt":"2017-12-01T11:26:57","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=4837"},"modified":"2021-08-25T17:26:24","modified_gmt":"2021-08-25T11:56:24","slug":"r-data-reshaping-function-package","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/","title":{"rendered":"R Data Reshaping &#8211; 4 Major Functions to Organise your Data!"},"content":{"rendered":"<p>In this tutorial, we will discuss about data reshaping in R. We will also cover data frame concepts as data reshaping is totally dependent on a data frame in R. Along with this, we will also learn different properties of a data frame which will help you out in understanding these concepts.<\/p>\n<h2>Introduction to R Data Reshaping<\/h2>\n<p><span style=\"font-weight: 400\">R data reshaping is all about changing the way in which data is organized into rows and columns. Most of the time data processing in R is done by taking the input data as a data frame. Also, extracting data from the rows and columns of a data frame is an easy task but there are situations when we need the data frame in a format that is different from the format in which we received it. In R, it has many functions to split, merge and change the rows to columns in a data frame.<\/span><\/p>\n<h3>Why Reshape R Package?<\/h3>\n<p><span style=\"font-weight: 400\">For analytic functions, the data obtained as a result of an experiment or study is generally different. Usually, the data from a study has one or more columns that can identify a row followed by a number of columns that represent the values measured. The columns that identify the row can be thought of as a<strong> composite key of a database column<\/strong>.<\/span><\/p>\n<p><em><strong>To understand this concept of reshaping data R, knowledge of the matrix is very necessary. So, here is the <a href=\"https:\/\/data-flair.training\/blogs\/r-matrices-operations-applications\/\">R Matrix tutorial<\/a> for you.<\/strong><\/em><\/p>\n<h3>Joining Columns and Rows in a Data Frame<\/h3>\n<p><span style=\"font-weight: 400\">We use\u00a0vectors to create a data frame using the cbind()function.<\/span><\/p>\n<h3>1. cbind()<\/h3>\n<p><span style=\"font-weight: 400\">We use cbind() function to combine vector, matrix or data frame by columns.<\/span><\/p>\n<p><span style=\"font-weight: 400\">cbind(x1,x2,&#8230;)<\/span><br \/>\n<span style=\"font-weight: 400\">x1,x2: vector, matrix, data frames<\/span><b><\/b><\/p>\n<h3>2. rbind()<\/h3>\n<p><span style=\"font-weight: 400\">We use rbind() function to combine vector, matrix or data frame by rows.<\/span><\/p>\n<p><span style=\"font-weight: 400\">rbind(x1,x2,&#8230;)<\/span><br \/>\n<span style=\"font-weight: 400\">x1,x2: vector, matrix, data frames<\/span><b><\/b><\/p>\n<p><em><strong>You must have a look at <a href=\"https:\/\/data-flair.training\/blogs\/r-vector-types-and-operations\/\">R Vector Operations<\/a><\/strong><\/em><\/p>\n<h3>3. melt()<\/h3>\n<p>We use melt() function in R to convert an object into a molten data frame. It takes input in the form of a wide format and stacks multiple columns into a single column of the data. The melt() function has the following attributes &#8211;<\/p>\n<p><em>melt(data, \u2026, na.rm = FALSE, value.name = \u201cvalue\u201d)<\/em><\/p>\n<ul>\n<li><strong>data<\/strong>\u00a0&#8211; The input data that is to be melted.<\/li>\n<li><strong>\u2026.<\/strong>\u00a0&#8211; Arguments that are passed to or from.<\/li>\n<li><strong>na.rm<\/strong>\u00a0&#8211; Used for converting explicit missings into implicit missings.<\/li>\n<li><strong>value.name<\/strong>\u00a0&#8211; Used for storing values in variables.<\/li>\n<\/ul>\n<p>In the following example, make use of the mtcars data and apply melt() function to the<strong> id variables<\/strong> &#8211; \u2018gears\u2019 and \u2018carbs\u2019 and the<strong> measured variables<\/strong> &#8211; \u2018mpg\u2019, \u2018cyl\u2019, \u2018disp\u2019, \u2018hp\u2019. We use this\u00a0melt function to melt the mtcars data frame.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">library(reshape)\r\nlibrary(datasets)\r\nstr(mtcars)\r\nmolted = melt(mtcars,id.vars=c(\"gear\",\"carb\"),measured.vars=c(\"mpg\",\"cyl\",\"disp\",\"hp\"))\r\nstr(molted)\r\nmolted[sample(nrow(molted),10),]<\/pre>\n<p><strong>Code Display:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/melt-function.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59785\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/melt-function.jpg\" alt=\"melt function - Reshape R\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/melt-function.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/melt-function-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/melt-function-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/melt-function-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/melt-function-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/melt-function-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/output_melt.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59787\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/output_melt.jpg\" alt=\"output melt\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/output_melt.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/output_melt-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/output_melt-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/output_melt-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/output_melt-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/output_melt-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><em><strong>Take a deep dive into <a href=\"https:\/\/data-flair.training\/blogs\/r-data-frame\/\">R Data Frame Operations<\/a><\/strong><\/em><\/p>\n<h3>4. dcast()<\/h3>\n<p>Once you have a molten dataset with you, it is ready to be cast or reshaped. We will construct the original dataset using the dcast() function. The dcast() function:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">head(dcast(molted,gear+carb~variable, length))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Decast.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59789\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Decast.jpg\" alt=\"Decast Output\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Decast.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Decast-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Decast-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Decast-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Decast-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/Decast-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>There are three arguments in dcast():<\/p>\n<ul>\n<li><strong>data &#8211;<\/strong> The data attribute taken in the molten data frame.<\/li>\n<li><strong>formula &#8211;<\/strong> The formula specifies how the data is to be cast. The formula is present in the form of x_variable ~ y_variable, but there can be multiple variables present.<\/li>\n<li><strong>fun.aggregate &#8211;<\/strong>\u00a0We use this function if there is data aggregation due to implementation of the casting formula. (example &#8211; length(), mean() and sum() ).<\/li>\n<\/ul>\n<p>What if we use only one of the variables gear or carb in dcast()?<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">dcast(molted,gear~variable,mean)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-mean.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59790\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-mean.jpg\" alt=\"decast mean output\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-mean.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-mean-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-mean-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-mean-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-mean-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-mean-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>We can also perform a transpose operation on this as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; dcast(molted,variable~gear,mean) #Author DataFlair<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-transpose.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-59791 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-transpose.jpg\" alt=\"decast transpose output - R Data Reshaping\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-transpose.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-transpose-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-transpose-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-transpose-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-transpose-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-transpose-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>We can also avail . (dot) which does not signify any variable:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; dcast(molted,variable~.,mean) #Author DataFlair<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-dot.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-59792 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-dot.jpg\" alt=\"decast dot output - R Data Reshaping\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-dot.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-dot-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-dot-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-dot-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-dot-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-dot-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>We can also perform:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; dcast(molted,carb~.,mean) #DataFlair<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-carb.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-59793 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-carb.jpg\" alt=\"decast carb output - R Data Reshaping\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-carb.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-carb-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-carb-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-carb-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-carb-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-carb-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>Margins, that are known as column totals can be created by specifying an attribute \u2018margin\u2019 and setting it to TRUE.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">dcast(molted,variable~gear,mean,margins=TRUE)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-margin-output.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-59794 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-margin-output.jpg\" alt=\"decast margin output - R Data Reshaping\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-margin-output.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-margin-output-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-margin-output-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-margin-output-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-margin-output-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/decast-margin-output-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<h2>Merging Data Frames in R<\/h2>\n<p><span style=\"font-weight: 400\">In order to combine the two data frames in <a href=\"https:\/\/journal.r-project.org\/\">R<\/a>, we make use of the merge() function.\u00a0The data frames must have the same column names on which the merging happens.<\/span><br \/>\n<b><\/b><\/p>\n<p><b>Adding Columns<\/b><\/p>\n<p><span style=\"font-weight: 400\">To merge two data frames (datasets) horizontally, we use the merge function. Mostly, we use it to join two data frames by one or more common key variables (i.e., an inner join).<\/span><\/p>\n<p><span style=\"font-weight: 400\"># merge two data frames by ID<\/span><br \/>\n<span style=\"font-weight: 400\">total &lt;- merge(data frameA,data frameB,by=&#8221;ID&#8221;)<\/span><\/p>\n<p><span style=\"font-weight: 400\"># merge two data frames by ID and Country<\/span><br \/>\n<span style=\"font-weight: 400\">total &lt;- merge(data frameA,data frameB,by=c(&#8220;ID&#8221;,&#8221;Country&#8221;)) .<\/span><\/p>\n<p>This was all in the R Data Reshape tutorial. Hope you liked the article.<\/p>\n<h2>Summary<\/h2>\n<p>We have studied\u00a0how to reshape data in R in a detailed manner. We have\u00a0also learned about the data frame and its properties. Data frame helps you in every single concept of data reshaping as they are linked to data frame only.<\/p>\n<p><em><strong>Next up in our R programming DataFlair tutorial series &#8211; <a href=\"https:\/\/data-flair.training\/blogs\/object-oriented-programming-in-r\/\">Object Oriented Programming (OOP ) in R<\/a><\/strong><\/em><\/p>\n<p>If you have any questions regarding the R data reshaping, leave the comment below. We&#8217;ll answer it and help you out. Thank you for reading\ud83d\ude00<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:2192,&quot;href&quot;:&quot;https:\\\/\\\/journal.r-project.org&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251211023659\\\/https:\\\/\\\/journal.r-project.org\\\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-01-14 02:51:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-22 10:37:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 20:49:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 22:04:33&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-12 16:50:52&quot;,&quot;http_code&quot;:503}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-12 16:50:52&quot;,&quot;http_code&quot;:503},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will discuss about data reshaping in R. We will also cover data frame concepts as data reshaping is totally dependent on a data frame in R. Along with this, we&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":59796,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[20189,11173,20188],"class_list":["post-4837","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r","tag-merging-data-frames-in-r","tag-r-data-reshaping","tag-reshape-r-package"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>R Data Reshaping - 4 Major Functions to Organise your Data! - DataFlair<\/title>\n<meta name=\"description\" content=\"In R data reshaping tutorial, learn the need of reshaping R package, how to reshape data in R by joining rows &amp; columns in data frame and merging data frames in R.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"R Data Reshaping - 4 Major Functions to Organise your Data! - DataFlair\" \/>\n<meta property=\"og:description\" content=\"In R data reshaping tutorial, learn the need of reshaping R package, how to reshape data in R by joining rows &amp; columns in data frame and merging data frames in R.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-01T11:26:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-25T11:56:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/R-Data-Reshaping-01-1.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=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"R Data Reshaping - 4 Major Functions to Organise your Data! - DataFlair","description":"In R data reshaping tutorial, learn the need of reshaping R package, how to reshape data in R by joining rows & columns in data frame and merging data frames in R.","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:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/","og_locale":"en_US","og_type":"article","og_title":"R Data Reshaping - 4 Major Functions to Organise your Data! - DataFlair","og_description":"In R data reshaping tutorial, learn the need of reshaping R package, how to reshape data in R by joining rows & columns in data frame and merging data frames in R.","og_url":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2017-12-01T11:26:57+00:00","article_modified_time":"2021-08-25T11:56:24+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/R-Data-Reshaping-01-1.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"R Data Reshaping &#8211; 4 Major Functions to Organise your Data!","datePublished":"2017-12-01T11:26:57+00:00","dateModified":"2021-08-25T11:56:24+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/"},"wordCount":849,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/R-Data-Reshaping-01-1.jpg","keywords":["Merging Data Frames in R","R data reshaping","Reshape R Package"],"articleSection":["R Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/","url":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/","name":"R Data Reshaping - 4 Major Functions to Organise your Data! - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/R-Data-Reshaping-01-1.jpg","datePublished":"2017-12-01T11:26:57+00:00","dateModified":"2021-08-25T11:56:24+00:00","description":"In R data reshaping tutorial, learn the need of reshaping R package, how to reshape data in R by joining rows & columns in data frame and merging data frames in R.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/R-Data-Reshaping-01-1.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/R-Data-Reshaping-01-1.jpg","width":802,"height":420,"caption":"R Data Reshaping"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/r-data-reshaping-function-package\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"R Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/r\/"},{"@type":"ListItem","position":3,"name":"R Data Reshaping &#8211; 4 Major Functions to Organise your Data!"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/4837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=4837"}],"version-history":[{"count":12,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/4837\/revisions"}],"predecessor-version":[{"id":63465,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/4837\/revisions\/63465"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/59796"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=4837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=4837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=4837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}