Copy Data from Excel to R


R Data Science: R Programming A-Z: R For Data Science With Real Exercises!

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
Coursera Data Science

R Tutorials : 75 Free R Tutorials

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

2 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

Next → ← Prev