KEMBAR78
01.Session-notes-Data Import | PDF | Computer File | Data
0% found this document useful (0 votes)
23 views3 pages

01.Session-notes-Data Import

Uploaded by

nairsuraj725
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

01.Session-notes-Data Import

Uploaded by

nairsuraj725
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Sessions notes-1

Data Import to R

In this section, I will discuss the steps to be adopted for importing excel files into R. Please
note that files with other extensions also can be imported into R. But, for time being I will
mainly concentrate on excel files. I will discuss importing other extensions in the later
sessions.

Let us first be comfortable with the excel files. All of us know that the data collected, either
primary or secondary, usually will be entered or stored in an excel file.

The data is stored as rows and columns. While rows indicate the responses, columns
indicate the variables on which the data is collected.

One can visualize a data set in excel file as a matrix that deals with various aspects related
to the given situation. Note that, a given situation can be understood by exhaustively listing
all possible parameters that one can list. Only then the data is said to be complete. One can
make the data complete either by experience or by taking expert advise or by conducting a
thorough literature review. Once the list is ready, then one has to associate a variable with
each parameter.

For example, the parameters can be average revenue, average expense, median salary,
average number customers, average customer satisfaction etc. Corresponding to these, one
can associate variables such as revenue, expense, salary, number of customers, customer
satisfaction etc. Each variable is measured using appropriate scale. Note that, the
parameters can be categorical as well. Like, proportion of customer who are unhappy with
the service and the corresponding variable will be a binary response variable-happy
customer or not. It all depends on what we are measuring.
Let us move forward with the import of excel files to R. Note that, in order to import the
excel files to R, one has to download and install the corresponding package. It is easy to
remember the package names. For example, we need to read an excel file and the
corresponding package is “readxl”. We need to install the package and then call the
package. Once we install the package, it will be downloaded to a temporary folder and we
can call it whenever we need it. The following is the code for the same.

Install the package

install.packages(“readxl”)

call the package

library(readxl)

Importing the data file

The data considered for the session is the “Customer satisfaction” data. This was
introduced to you all in term-1. I want to consider the same and explain the process of
conducting the analysis in R completely. In order to import the data file, the following codes
are used

cust_sat=read_excel(file.choose())

Here, cust_sat is the data file name assigned in R. read_excel() is the built-in function that
comes along with the “readxl” package. If one knows the path where the excel file is stored,
then the same can be copied to the function. In case if one doesn’t know the path, then the
file.choose() function can be used. As soon as this is used, a new window with name “select
file” will be opened. Sometimes it will be not shown directly. In such cases, one has to use
alt+tab to check for the window. Note that, R is case sensitive and one has to be careful
while typing the codes in R. Once the window is opened, one can navigate to the folder
where the excel file is stored and import the excel file to R. Assume that you have two or
three sheets in the same excel file. Then, one has to specify the sheet name in the
read_excel() function. For example, read_excel(file.choose(), sheet= “name of the sheet”).
Once the data import is done, one has to attach the data file.

Attaching the data file to R

attach(cust_sat)

Opening the data file in the Reditor

fix(cust_sat)

Note that the Reditor has to be closed before excuting any other code. Till it is closed, other
codes will not be executed.

Viewing the data in R as seperate window

View(cust_sat)

After viewing the data in R, one can start understanding the data set and start the analysis.
Data analysis should be always linked to the objectives of the study. It is a one-to-one link
between the both. The variables from the data set have to be identified and the
corresponding data should be analyzed to draw appropriate inferences. I now discuss this
in detail and then explain how to analyze the data using R.

The data is related to a store, where the store in-charge wants to

table(cust_sat$Gender)

You might also like