Import Data, Copy Data from Excel to R, Both .csv and .txt Formats (R Tutorial 1.3)

Import Data, Copy Data from Excel to R, Both .csv and .txt Formats (R Tutorial 1.3)


Learn how to import or copy data from excel (or other spreadsheets) into R using both comma-separated values and tab-delimited text file. You will learn to use "read.csv", "read.delim" and "read.table" commands along with "file.choose", "header", and "sep" arguments.
This video is a tutorial for programming in R Statistical Software for beginners.

You can access the dataset here:
our website: http://www.statslectures.com/index.php/r-stats-videos-tutorials/getting-started-with-r/1-3-import-excel-data

or here:

Excel Data Used in This Video: http://bit.ly/1uyxR3O

Excel Data Used in Subsequent Videos: https://bit.ly/LungCapDataxls
Tab Delimited Text File Used in Subsequent Videos: https://bit.ly/LungCapData


Here is a quick overview of the topics addressed in this video; You can click on the time stamp to jump to the specific topic:

0:00:17 introducing the two main file types for saving a data file

0:00:36 how to save a file in excel as a csv file ("comma-separated value")

0:01:10 how to open a comma-separated (.csv) data file into excel

0:01:20 how to open a comma-separated (.csv) data file into a text editor

0:01:36 how to import comma-separated (.csv) data file into R using "read.csv" command

0:01:44 how to access the help menu for different commands in R

0:02:04 how to use "file.choose" argument on "read.csv" command to specify the file location in R

0:02:31 how to use the "header" argument on "read.csv" command to let R know that data has headers or variable names

0:03:22 how to import comma-separated (.csv) data file into R using "read.table" command

0:03:38 how to use "file.choose" argument on "read.table" command to specify the file location in R

0:03:41 how to use the "header" argument on "read.table" command to let R know the data has headers or variable names

0:03:46 how to use the "sep" argument on "read.table" command to let R know how the data values are separated

0:04:10 how to save a file in excel as tab-delimited text file

0:04:50 how to open a tab-delimited (.txt) data file into a text editor

0:05:07 how to open a tab-delimited (.txt) data file into excel

0:05:20 how to import tab-delimited (.txt) data file into R using "read.delim" command

0:05:44 how to use "file.choose" argument on "read.delim" command to specify the file path in R

0:05:49 how to use the "header" argument on "read.delim" command to let R know that the data has headers or variable

0:06:06 how to import tab-delimited (.txt) data file into R using "read.table" command

0:06:20 how to use "file.choose" argument on "read.table" command to specify the file location

0:06:23 how to use the "header" argument on "read.table" command to let R know that the data has headers or variable names

0:06:27 how to use the "sep" argument on "read.table" command to let R know how the data values are separated
Closed Caption:

Hi! I am Mike Marin and in this video
we'll talk about
how to import data from Excel into R.
the steps outlined in this video
should work with most other spreadsheet
applications
but since Excel is fairly commonly used
we will focus our discussion on this
Our two main options will be to save the
data file
as a comma-separated value or ".csv"
file or as a tab-delimited text file
with the ".txt" extension. Saving it as a
csv file
is probably easier and the better way to
go! let's go ahead and save this file
on the desktop as a csv file: to do so
under the "File menu" we can go to "Save As..."
we're going to save it on our desktop
and we can save this as a
"comma-separated" value
or csv file. I'm also gonna add the
CSV to the end of the file name just so
it's easily identifiable
we can see
the ExceldataCSV file saved here on
the desktop
you'll notice if we double click on this
file to open it
by default it will open in Excel
let's go ahead and close this. You'll notice if
we right click
on this file we can "Open With..." and open
it in any text editor that we like
this here is what the csv file looks
like
in a text editor. okay so let's go ahead
and import this data into R. so I've gone
ahead and
opened up RStudio and R. the first
option for importing data
is to use the "read.csv" command. you can
access the Help menu
by typing help and in brackets the name
of the command you will like help for
or by placing a question mark (?) in front of the
command name;
let's go ahead and import this data into R
and save it in an object called "data1".
To do so
we will use the "read.csv" command. the first
argument to specify
is the "file". normally R would like us
to specify
the path to find the file here but a
handy command to know
in R is the "file.choose" command.
rather than specifying the path to find this file
we can use the "file.choose" command and
this will result in a menu popping up
allowing us to select the data file
directly. the next argument that we
should worry about
is the "header" argument. we can set this
equal to TRUE
using capital letters to let R know that
the first row of our dataset
are variable names or headers. if the
first row does not contain variable
names we would set the sequel to FALSE
it's also worth noting that we only need
to provide a capital T
and R will know this is TRUE. we can
then submit this command
by hitting the "enter" or "return" key on our
keyboard. we can now go and find this
file that we saved on the desktop : our "ExceldataCSV.CSV"
select this file and now
if we type in the object's name "data1"
we can see the entire dataset return to us.
it looks like R has imported this dataset correctly
we can also see in the workspace this
object data1
which has 10 observations on 6
variables
we can also import this data using the
more generic
"read.table" command. lets demonstrate
the use of this command
and import the data into R and save it
in an object called "data2"
here we will use the "read.table" command
again we will use the "file.choose" command
we will set the "header" argument
equal to TRUE
and here we also need to use the "sep"
argument
letting R know how the data values are
separated
in quotations we will place a comma letting
R know these are comma separated values
we can then submit this command, go on our
desktop
select the "ExceldataCSV.CSV" file
and when we type in the name of this
object
again we can see the data has been
imported correctly.
now let's go back to our excel file
and look at importing data saved as a
tab-delimited text file
once again you can see our Excel data file
we can go ahead and save this file as a
tab-delimited text file
here I will select the tab-delimited file with a .txt
extension and we will also
add the word TAB to the end of this file name, so
we can be easily identify this is the
tab-delimited file. we can then save it
and now we can see this tab-delimited
text file saved on the desktop here
you'll notice if you double-click on this
file to open it
by default it will be opened in a text
editor
you can also notice these values are
separated by tabs
let's go ahead and close this down. to
open this file
using Excel we can right click
"open with" and select Microsoft Excel
and now we'll see our tab-delimited text
file opened up in Excel
now let's go back into RSstudio and
import this data file
we can use the "read.delim" command in R
to import a tab-delimited text file
let's go ahead and import this dataset
using the "read.delim" command
and we will save the data into an object
called data3
we will use the "read.delim" command
as before we use the "file.choose" command
so that we can select our file from menu
we can set the "header" argument equal to
TRUE once we enter this command:
we can go onto the desktop open up our
tab-delimited
text file. again if we enter the object
name
we can see the data has been imported
correctly
and finally as we saw before we could
also use the more generic
"read.table" command. let's demonstrate
this and save the
data in an object called data4
we'll use the "read.table" command. again
"file.choose" so that we can select our
file
"header" equal to TRUE and finally we
can set
the "sep" argument equal to back-slash t (\t)
letting R know this is a tab-delimited file
we can go ahead and select the file
we can enter the dataset's name to view it
and again the data looks as it should. the
next video in the series
talks a bit more about importing data
and then how to get started working with
the data in R
once you've imported it. thanks for
watching this video
and make sure to check out my other
instructional videos

Video Length: 06:59
Uploaded By: MarinStatsLectures
View Count: 296,513

Related Software Products
Convert Excel To CSV
Convert Excel To CSV

Published By:
Excel-Tool

Description:
Convert Excel to CSV Software is a batch csv converter that converts Excel to CSV files. It allows you to convert each Excel sheet to a new CSV file in one or more Excel files. The software can help you convert a lot of Excel to CSV files once time for saving your time. The program supports command line interface. So, you can run it with necessary parameters in a batch mode from the command line or from Windows scheduler without human beings. With Convert Excel to CSV software you may: 1. ...


Related Videos
Convert Excel Spreadsheet data to XML
Convert Excel Spreadsheet data to XML

Here is a quick video on how to convert Excel spreadsheet data to XML for import into Flash or Flex. Don't spend time typing all that data again create a schema and convert to XML. Convert Excel was created by Mike Lively Director of A&S Instructional Design at Northern Kentucky University NKU. hr / bClosed Caption:/b hello this is Mike lively from Northern Kentucky University and today we're going to show you how to convert that Excel spreadsheet into ...
Video Length: 04:13
Uploaded By: Michael Lively
View Count: 427,607

How to Import CSV File Into Excel
How to Import CSV File Into Excel

How to Convert CSV to XLS Importing CSV Files into Excel How to convert a csv file to Excel 2010 Convert a CSV File to Excel XLS Importing Text Files in an Excel Sheet CSV to XLS Converting a Text File (.txt, .prn, .csv) to an Excel 2003/2007/2010 How do you Convert CSV files to Excel How to Import Contacts from Excel or a CSV File How To Import a CSV File Containing a Column With a Leading How do I make a CSV file for import from Excel?br ...
Video Length: 02:40
Uploaded By: ProgrammingKnowledge2
View Count: 199,119

Importing CSV Files into Excel
Importing CSV Files into Excel

This is a tutorial on how to import CSV files into excel. I recommend using the "text import wizard" because it lets you work with "delimited" files. CSV files are delimited by commas whereas .txt files are separated by tabs. hr / bClosed Caption:/b so this is a tutorial on how to import a csv that's comma separated value file into excel right now I'm on yahoo finance going to historical prices and as you can tell there's just jobs of data ...
Video Length: 03:20
Uploaded By: ExcelHelpWM
View Count: 146,530

Convert Excel To CSV
Convert Excel To CSV

How to convert lead files from note pad and excel to CSV hr / bClosed Caption:/b all righty right now what I've done was I'm it were in Excel and I want you to know that right now only thing I'm going to show you right now is how to convert a notepad file to a CSV file so we're gonna go ahead and open up my open up my wife older look for somewhere where I may have a notepad folder and see if I can get one got onebr ...
Video Length: 03:58
Uploaded By: Dwayne Golden
View Count: 137,550

How to convert spb file extension to csv file extension ?
How to convert spb file extension to csv file extension ?

This video helps you to convert your contact file which is in .spb extension (Supported by Samsung Kies) to .CSV file extension in order to view the contacts in Microsoft Excel. You can even upload this .csv file to gmail contacts and then you can import it to your Android device easily. Download Samsung Kies Version that supports this conversion: https://www.dropbox.com/s/3fzz54xuq9i... https://www.youtube.com/watch?v=xi2Fa...
Video Length: 01:58
Uploaded By: Paresh Gujarati
View Count: 81,183

How to export or save a .csv file from Excel
How to export or save a .csv file from Excel

This video show you how to save or export a comma delimited file, or -csv- file from excel in order to import into your conXt address book or many other places. hr / bClosed Caption:/b in this video I'm going to show you how to save an excel file as a CSV file or comma delimited file as it's known and the file that we will end up with is a dot CSV extension in it and that's the kind of file that you will need to upload it to connect ...
Video Length: 02:31
Uploaded By: conXtAddressBook
View Count: 73,786

Convert a Column or Rows of Data into Comma Separated Values
Convert a Column or Rows of Data into Comma Separated Values

http://myexcelcharts.blogspot.com CSV. This is the acronym for comma separated values or Cash Surrender Value (if you are selling insurance). But this is not an insurance blog so I'll stick with the former definition. If you work with data, sometimes you get it in one format and you've got to put it into another format to get more data. In this case you get a list of values in a column and you'd need to take that list and input it into some program to get more data. But the ...
Video Length: 03:44
Uploaded By: Doug H
View Count: 66,026

Excel Magic Trick #133: Import CSV Data (Comma Separated Values - Data)
Excel Magic Trick #133: Import CSV Data (Comma Separated Values - Data)

See how to import files with the extension .csv. See how to use the Text Import Wizard to import data into Excel. See how to use the Text To Column Excel Feature. Comma Separated Values - Data hr / bClosed Caption:/b welcome to exhale magic number a hundred and thirty-three hey if you want to download this workbook and follow along click on my youtube channel then click on my college website link and download the workbook XL maxi ...
Video Length: 07:07
Uploaded By: ExcelIsFun
View Count: 65,988

Copyright © 2025, Ivertech. All rights reserved.