Copy Data from Excel to R

Deepanshu Bhalla 5 Comments
This tutorial explains how we can create data in MS Excel and paste it to R syntax editor window to create a table in R. MS Excel is one of the most frequently used tools in analytics industry. Many companies have switched their core analytics work from Excel to R / SAS but we still find some of the data in excel file.

If you prefer to import excel file to R rather than copying and paste excel data to R, you can check out this tutorial - Importing Data to R

Step 1 :  Prepare Data in Excel

Step 2 : Paste Data under text= "   " section of read,table (See the image below)

Prepare Data in Excel and Paste it to R Editor

data = read.table(text="
X Y Z
6 5 0
6 3 NA
6 1 5
8 5 3", header=TRUE)

It creates 3 columns - X, Y and Z. The header = TRUE tells R to consider first row as header.

Related Data : Import Data into R
Related Posts
Spread the Word!
Share
About Author:
Deepanshu Bhalla

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and HR.

Post Comment 5 Responses to "Copy Data from Excel to R"
  1. This somehow doesn't seem correct. Instead of giving location like C:\Documents\Folder\xyz.xlsx\Sheet1$A1:$D6. The example given doesn't seem from copy data from excel to R.

    ReplyDelete
    Replies
    1. This article is not about how to import data from Excel into R. You can check out this link -
      Import Data into R

      Delete
  2. Great and very helpful work, thanks a lot

    ReplyDelete
  3. Love your work. Thank you very much.

    ReplyDelete
  4. wow this is so simple and fantastic. didn't know you can do that.

    ReplyDelete
Next → ← Prev