

{"id":1804,"date":"2017-03-25T09:05:08","date_gmt":"2017-03-25T09:05:08","guid":{"rendered":"http:\/\/data-flair.training\/blogs\/?p=1804"},"modified":"2021-08-25T18:21:07","modified_gmt":"2021-08-25T12:51:07","slug":"importing-data-in-r","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/","title":{"rendered":"Importing Data in R Programming &#8211; Easy to Follow Guide for Beginners!"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:2197,&quot;href&quot;:&quot;https:\\\/\\\/www.r-project.org\\\/mail.html&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20250923123815\\\/https:\\\/\\\/www.r-project.org\\\/mail.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-11 02:30:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-15 15:57:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-20 17:10:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-25 14:56:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-29 06:15:36&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-01-06 14:58:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-09 19:59:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-15 07:02:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-18 20:33:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-22 09:45:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-25 20:29:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-01 15:58:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-04 16:56:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 00:30:49&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-12 23:36:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-16 10:34:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 18:55:30&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-24 08:47:46&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 09:24:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-02 12:35:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-05 17:16:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 15:35:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 20:57:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-16 06:08:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-20 03:17:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 05:26:49&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-01 02:55:55&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-06 06:09:23&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-09 13:50:53&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-13 07:12:36&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-20 20:41:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-25 09:59:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-29 16:16:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-03 04:24:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-06 05:00:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-09 11:59:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-12 19:12:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-18 14:26:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-22 10:34:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-26 03:16:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-29 10:14:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-01 20:22:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-05 03:35:35&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-05 03:35:35&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>In this tutorial, we will learn how to import data from various sources into the R programming environment. We will make use of the commands in R such as<em> c(), scan()<\/em>. Also, we will draw a comparison between read.csv() and read.csv2() in R for importing the various CSV files. Furthermore, we will explore the read.delim() function for importing the data.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63278\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming.jpg\" alt=\"Importing Data in R programming\" width=\"802\" height=\"420\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming.jpg 802w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming-520x272.jpg 520w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/a><\/p>\n<p>So, let&#8217;s quickly start importing data in R.<\/p>\n<h2>Process of Importing Data in R<\/h2>\n<p>Now, let&#8217;s explore the steps to import data in R:<\/p>\n<h3>1. Using the Combine Command<\/h3>\n<p>In R, we make use of c() function <em>to combine or concatenate various data values together.<\/em><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; #Author DataFlair\r\n&gt; vector1 &lt;- c(1,2,3)\r\n&gt; vector2 &lt;- c(4,5,6)\r\n&gt; vector3 &lt;- c(7,8,9)\r\n&gt; combined_vector &lt;- c(vector1, vector2, vector3)\r\n&gt; combined_vector\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/combine_command.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63230\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/combine_command.jpg\" alt=\"combine_command - Importing Data in R\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/combine_command.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/combine_command-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/combine_command-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/combine_command-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/combine_command-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/combine_command-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>In the above example, vector1, vector2 and vector3 store integer values separately. To combine these values together, we make use of the c() function, as demonstrated above.<\/p>\n<p><em><strong>Before proceeding ahead, first, complete the <a href=\"https:\/\/data-flair.training\/blogs\/binomial-and-poisson-distribution\/\">Binomial and Poisson Distribution in R<\/a><\/strong><\/em><\/p>\n<h3>2. Entering Numerical Items as Data<\/h3>\n<p>We can simply enhance numerical data by typing the values separated by commas into the c() command.<\/p>\n<p>Let us create a data set by using the below command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; #Author DataFlair\r\n&gt; data1 = c(3, 5, 7, 5, 3, 2, 6, 8, 5, 6, 9)\r\n&gt; data1\r\n<\/pre>\n<p>We will create an object data1 that stores our data. Then, type our values between the two parentheses and these values will be separated by commas. In order to display the dataset, type &#8216;data1&#8217;.<\/p>\n<p>After that, carry out the same with the data object &#8211; data2. In this, we will also specify data1 as one of the member components.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; data2 = c(data1, 4, 5, 7, 3, 4)\r\n&gt; data2<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Entering-Numerical-Items.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63231\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Entering-Numerical-Items.jpg\" alt=\"Entering Numerical Items - Importing Data in R\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Entering-Numerical-Items.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Entering-Numerical-Items-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Entering-Numerical-Items-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Entering-Numerical-Items-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Entering-Numerical-Items-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Entering-Numerical-Items-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<h3>3. Entering Text Items as Data<\/h3>\n<p>In order to enter character data, we make use of single quotes or double-quotes. Whatever is covered by these quotes is interpreted like a character type or a text item.\u00a0 In the following example, we will take our data in the form of characters as the days of a week. We will store them in the day1 object. Then, we will pass day1 into the same vector along with another text item. However, day1, in this case, is not text but numerical in nature. If there is a combination of numbers and text, R converts the number into text.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; #Author DataFlair\r\n&gt; day1 = c('Mon', 'Tue', 'Wed', 'Thu')\r\n&gt; day1\r\n&gt; day1 = c(day1, 'Fri')\r\n&gt; day1\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Text.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63233\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Text.jpg\" alt=\"Importing Text\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Text.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Text-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Text-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Text-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Text-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Text-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><em><strong>Don&#8217;t forget to check the <a href=\"https:\/\/data-flair.training\/blogs\/r-numeric-and-character-functions\/\">Numeric and Character Functions in R<\/a><\/strong><\/em><\/p>\n<h3>4. Using the scan() command<\/h3>\n<p>Instead of typing input data with the additional specification of commas, we can use the scan() command that <em>does not require you to enter a comma after every input data.<\/em> scan() can also be used for taking data from files as well as with the clipboards.<\/p>\n<p>scan() command does not take any input between its parentheses. It simply invokes a prompt through which you enter the data.<\/p>\n<p>Let us see this with the help of an example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">data &lt;- data.frame(x1 = c(1, 2, 3, 4),          \r\n                  x2 = c(5, 6, 7, 8),\r\n                  x3 = c(9, 10, 11, 12))\r\ndata\r\n\r\nwrite.table(data, file = \"data.txt\", row.names = FALSE)\r\ngetwd()\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63234\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-1.jpg\" alt=\"scan () command 1\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-1.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-1-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-1-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-1-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-1-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-1-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>In the above example, we created a data frame which is then stored as a file on the local disk called &#8216;data.txt&#8217;. This file can be accessed using the scan function as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; #Author DataFlair\r\n&gt; scan_data &lt;- scan(\"data.txt\", what = \"character\")\r\n&gt; scan_data\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-63236 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-2.jpg\" alt=\"scan data 2 - Importing Data in R\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-2.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-2-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-2-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-2-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-2-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-2-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<h3>5. Using the Clipboard to Make Data<\/h3>\n<p>We can use the clipboard to copy and paste the data more interactively. With the scan() command, we can enter the input data such as spreadsheets.<\/p>\n<p>Following are the key steps for importing spreadsheet data into R:<\/p>\n<ol>\n<li>If the spreadsheet contains numerical data, then prior to switching to this spreadsheet, type command in R.<\/li>\n<li>We copy the important cells to the clipboard after highlighting them.<\/li>\n<li>After returning to <a href=\"https:\/\/www.r-project.org\/mail.html\">R<\/a>, paste the data from clipboard into R. Then, R waits until an empty line is entered before halting the data entry process in order to facilitate data copying and pasting as required.<\/li>\n<li>Finally, a blank line is entered to complete the data entry procedure.<\/li>\n<\/ol>\n<p>If there are spaces separating the data, then perform simple copy and paste. However, if some other symbol or character is separating the data, then we need to input that into R prior to data import.<\/p>\n<p><em><strong>Take a deep dive into <a href=\"https:\/\/data-flair.training\/blogs\/data-visualization-in-r\/\">R Data Visualization<\/a><\/strong><\/em><\/p>\n<h3>6. Using Scan() to Retrieve Data from CSV file<\/h3>\n<p>We can use the scan() command to retrieve data from a CSV file. We will save our previously created data frame &#8216;data&#8217; as a CSV file.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">write.table(data, file = \"data.csv\",\r\n           row.names = FALSE)\r\ngetwd()\r\n<\/pre>\n<p>In the next step, we scan our CSV file and specify the what attribute with &#8216;character&#8217;.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">write.table(data, file = \"data.csv\",\r\n            row.names = FALSE)\r\n getwd()\r\n scan_csv &lt;- scan(\"data.csv\", what = \"character\")\r\n scan_csv\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-csv-.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63239\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-csv-.jpg\" alt=\"scan csv - Importing Data in R\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-csv-.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-csv--150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-csv--300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-csv--768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-csv--1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/scan-csv--520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>This separator needs to be enclosed in quotes. In order to finish the data entry, press <strong>Enter<\/strong>.<\/p>\n<h3>7. Reading a File of Data from a Disk<\/h3>\n<p>We can use the scan() command to get data file from the local memory of our system.<\/p>\n<p>With the help of scan(), data can be read from a console and written into a vector. We add the file name in the scan() function as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#Author DataFlair\r\n Object_Name &lt;- scan(\"data.txt\", what = \"character\")\r\n Object_Name\r\n getwd()\r\n setwd('Desktop')\r\n getwd()\r\n\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Reading-a-File-of-Data-from-a-Disk.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63243\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Reading-a-File-of-Data-from-a-Disk.jpg\" alt=\"Reading a File of Data from a Disk\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Reading-a-File-of-Data-from-a-Disk.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Reading-a-File-of-Data-from-a-Disk-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Reading-a-File-of-Data-from-a-Disk-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Reading-a-File-of-Data-from-a-Disk-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Reading-a-File-of-Data-from-a-Disk-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Reading-a-File-of-Data-from-a-Disk-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><em><strong>You must definitely explore the <a href=\"https:\/\/data-flair.training\/blogs\/r-vector-functions\/\">Types of R Vector Functions<\/a><\/strong><\/em><\/p>\n<h3>8. Reading Bigger Data Files<\/h3>\n<p>Now, we will learn how to read bigger data files in R.<\/p>\n<p>In the above sections, we used the scan() command to read data from simple files. In R, we can enter a large amount of data that contain complicated data. There are various means and measures to read such large data that is stored in a variety of text formats.<\/p>\n<ul>\n<li>We can read from csv file as: &gt; read.csv() or read.csv2()<\/li>\n<li>From tables with: &gt; read.table()<\/li>\n<li>In order to read from files that contain values separated by tabs: &gt; delim()<\/li>\n<\/ul>\n<p>read.csv() and read.csv2() both are used to read csv but the former makes use of <strong>&#8216;,&#8217;<\/strong> while the latter utilises the separator<strong> &#8216;;&#8217;<\/strong><\/p>\n<p>This was all about importing data into R. We hope that you liked reading our article!<\/p>\n<h2>Summary<\/h2>\n<p>In this R tutorial, we studied different methodologies of importing data into the R environment. We studied various commands that can be used for data import and understood their implementation with code examples.<\/p>\n<p><em><strong>After importing, it&#8217;s time for <a href=\"https:\/\/data-flair.training\/blogs\/exporting-data-from-r\/\">Exporting Data from R to CSV File<\/a><\/strong><\/em><\/p>\n<p>Still, if you have a query regarding Importing Data in R, ask in the comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will learn how to import data from various sources into the R programming environment. We will make use of the commands in R such as c(), scan(). Also, we will&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":63278,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[16680,20588,20589],"class_list":["post-1804","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r","tag-importing-data-in-r","tag-r-combine-command","tag-r-scan-command"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Importing Data in R Programming - Easy to Follow Guide for Beginners! - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn the process of importing data in the R programming environment from various sources by using commands c(), scan() with the help of code 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:\/\/data-flair.training\/blogs\/importing-data-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Importing Data in R Programming - Easy to Follow Guide for Beginners! - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn the process of importing data in the R programming environment from various sources by using commands c(), scan() with the help of code examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/\" \/>\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-03-25T09:05:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-25T12:51:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming.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=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Importing Data in R Programming - Easy to Follow Guide for Beginners! - DataFlair","description":"Learn the process of importing data in the R programming environment from various sources by using commands c(), scan() with the help of code 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:\/\/data-flair.training\/blogs\/importing-data-in-r\/","og_locale":"en_US","og_type":"article","og_title":"Importing Data in R Programming - Easy to Follow Guide for Beginners! - DataFlair","og_description":"Learn the process of importing data in the R programming environment from various sources by using commands c(), scan() with the help of code examples.","og_url":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2017-03-25T09:05:08+00:00","article_modified_time":"2021-08-25T12:51:07+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"Importing Data in R Programming &#8211; Easy to Follow Guide for Beginners!","datePublished":"2017-03-25T09:05:08+00:00","dateModified":"2021-08-25T12:51:07+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/"},"wordCount":983,"commentCount":3,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming.jpg","keywords":["Importing data in R","R Combine Command","R scan() command"],"articleSection":["R Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/importing-data-in-r\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/","url":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/","name":"Importing Data in R Programming - Easy to Follow Guide for Beginners! - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming.jpg","datePublished":"2017-03-25T09:05:08+00:00","dateModified":"2021-08-25T12:51:07+00:00","description":"Learn the process of importing data in the R programming environment from various sources by using commands c(), scan() with the help of code examples.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/importing-data-in-r\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/03\/Importing-Data-in-R-programming.jpg","width":802,"height":420,"caption":"Importing Data in R programming"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/importing-data-in-r\/#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":"Importing Data in R Programming &#8211; Easy to Follow Guide for Beginners!"}]},{"@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\/1804","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=1804"}],"version-history":[{"count":10,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/1804\/revisions"}],"predecessor-version":[{"id":63915,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/1804\/revisions\/63915"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/63278"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=1804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=1804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=1804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}