Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
25 views

R Programming Lab manual

R programming manual

Uploaded by

Yongho Louis
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

R Programming Lab manual

R programming manual

Uploaded by

Yongho Louis
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Master of Technology (M.

Tech)

Department of Computer Science and Engineering


II year I sem- DATA VISUALIZATION - R PROGRAMMING/ POWER BI
Laboratory Manual

HARVARD HIGHER INSTITUTE OF SCIENCES & TECHNOLOGY


HARVARD HIGHER INSTITUTE OF SCIENCES
AND TECHNOLOGY
Department of Computer Science and Engineering

Programme Outcomes
Engineering Knowledge: Apply the knowledge of mathematics, science, engineering
PO1 fundamentals, and an engineering specialization to the solution of complex engineering
problems.
Problem Analysis: Identify, formulate, review research literature, and analyze complex
PO2 engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
Design/development of Solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with
PO3
appropriate consideration for the public health and safety, and the cultural,
societal, and environmental considerations.
Conduct investigations of complex problems: Use research-based knowledge and
PO4 research methods including design of experiments, analysis and interpretation of data,
and synthesis of the information to provide valid conclusions.
Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modelling to complex
PO5
engineering activities with an understanding of the limitations.
The engineer and society: Apply reasoning informed by the contextual knowledge to
PO6 assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental context, and demonstrate the knowledge of, and
PO7
need for sustainable development.
Ethics: Apply ethical principles and commit to professional ethics and
PO8 responsibilities and norms of the engineering practice.
Individual and team network: Function effectively as an individual, and as a member
PO9 or leader in diverse teams, and in multidisciplinary settings.
Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, being able to comprehend and write
PO10
effective reports and design documentation, make effective presentations, and give and
receive clear instructions.
Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a
PO11
member and leader in a team, to manage projects and in multidisciplinary environments.

PO12 Life-Long learning: Recognize the need for, and have the preparation and able to
engage in independent and life-long learning in the broadest context of technological
change.

Program Specific Outcomes:

Program Applications: Able to develop programs modules for cloud based


PSO1
applications.
Development Tools: Able to use tools such as Weka, Rational Rose Raspberry-Pi,
PSO2
Sql and advanced tools
DATA VISUALIZATION - R PROGRAMMING/ POWER BI)
B.Tech. II Year I Sem. LTPC
0021
Course Objectives:
● Effective use of Business Intelligence (BI) technology (Tableau) to apply data visualization
● To discern patterns and relationships in the data.
● To build Dashboard applications.
● To communicate the results clearly and concisely.
● To be able to work with different formats of data sets.
Course Outcomes:
At the end of the course a student should be able to
● Understand How to import data into Tableau.
● Understand Tableau concepts of Dimensions and Measures.
● Develop Programs and understand how to map Visual Layouts and Graphical Properties.
● Create a Dashboard that links multiple visualizations.
● Use graphical user interfaces to create Frames for providing solutions to real world problems.
Lab Problems:
1. Understanding Data, What is data, where to find data, Foundations for building Data
Visualizations, Creating Your First visualization?
2. Getting started with Tableau Software using Data file formats, connecting your Data to
Tableau, creating basic charts(line, bar charts, Tree maps),Using the Show me panel.
3. Tableau Calculations, Overview of SUM, AVR, and Aggregate features, Creating custom
calculations and fields.
4. Applying new data calculations to your visualizations, Formatting Visualizations,
Formatting Tools and Menus, Formatting specific parts of the view.
5. Editing and Formatting Axes, Manipulating Data in Tableau data, Pivoting Tableau data.
6. Structuring your data, Sorting and filtering Tableau data, Pivoting Tableau data.
7. Advanced Visualization Tools: Using Filters, Using the Detail panel, using the Size panels,
customizing filters, Using and Customizing tooltips, Formatting your data with colors.
8. Creating Dashboards & Storytelling, creating your first dashboard and Story, Design for
different displays, adding interactivity to your Dashboard, Distributing & Publishing your
Visualization.
9. Tableau file types, publishing to Tableau Online, Sharing your visualizations, printing, and
Exporting.
10. Creating custom charts, cyclical data and circular area charts, Dual Axis charts.
REFERENCE BOOKS:
1. Microsoft Power BI cookbook, Brett Powell, 2nd edition.
2. R Programming for Data Science by Roger D. Peng (References) 3. The Art of R
Programming by Norman Matloff Cengage Learning India.
Aim : Understanding Data, What is data, where to find data, Foundations for
building Data Visualizations, Creating Your First visualization

Solution :

What is Data?

Data refers to raw facts, statistics, or information collected or stored in a structured


or unstructured form. Data can take various forms, such as text, numbers, images,
videos, and more. It is the foundation of all information and knowledge and is used
in various fields for analysis, decision-making, and understanding trends and
patterns.

Data can be categorized into two main types:

 Structured Data: This type of data is organized into a specific format, such as
tables or databases, and is easily searchable and analyzable. Examples include
spreadsheets, relational databases, and CSV files.
 Unstructured Data: Unstructured data lacks a specific format and can include
text documents, social media posts, images, audio recordings, and more.
Analyzing unstructured data often requires advanced techniques like natural
language processing and image recognition.

Where to Find Data?

You can find data from various sources, depending on your specific needs:

 Open Data Portals: Many governments and organizations provide free access
to a wide range of data through open data portals. Examples include Data.gov
(United States) and data.gov.uk (United Kingdom).
 Data Repositories: Academic institutions, research organizations, and data
enthusiasts often share datasets on platforms like Kaggle, GitHub, and the UCI
Machine Learning Repository.
 APIs (Application Programming Interfaces): Some websites and services offer
APIs that allow you to programmatically access and retrieve data. Examples
include Twitter API, Google Maps API, and financial market APIs.
 Web Scraping: You can extract data from websites using web scraping tools
and libraries like BeautifulSoup and Scrapy. However, be mindful of the
website's terms of use and legal restrictions.
 Surveys and Surveys: You can conduct your own surveys or collect data
through questionnaires and interviews.
 IoT Devices: Internet of Things (IoT) devices generate vast amounts of data
that can be used for various purposes.
 Commercial Data Providers: Some companies specialize in selling datasets for
specific industries, such as market research, finance, and healthcare.

Foundations for Building Data Visualizations:

Creating effective data visualizations requires a strong foundation in several key


areas:

 Data Analysis: Before creating visualizations, you should thoroughly analyze


your data to understand its structure, relationships, and any patterns or
trends. Exploratory data analysis (EDA) techniques can help with this.
 Statistical Knowledge: Understanding basic statistics is essential for making
meaningful interpretations of data. Concepts like mean, median, standard
deviation, and correlation are commonly used in data visualization.
 Domain Knowledge: Having knowledge of the specific domain or subject
matter related to your data is crucial for creating contextually relevant
visualizations. It helps you ask the right questions and provide valuable
insights.
 Visualization Tools: Familiarize yourself with data visualization tools and
libraries such as matplotlib, Seaborn, ggplot2, D3.js, and Tableau. Each tool
has its strengths and can be used for different types of visualizations.
 Design Principles: Study design principles, including color theory, typography,
and visual hierarchy, to create visually appealing and effective visualizations.
Avoid common pitfalls like misleading visualizations.
 Interactivity: Learn how to add interactive elements to your visualizations to
engage users and allow them to explore the data. This can be achieved using
tools like JavaScript, Python libraries, or dedicated visualization software.

Creating Your First Visualization:


To create your first data visualization, follow these general steps:

 Select Your Data: Choose a dataset that aligns with your goals and interests.
Ensure that the data is clean and well-structured.
 Define Your Objective: Clearly define what you want to communicate or
explore with your visualization. Are you looking to show trends, comparisons,
or distributions?
 Choose the Right Visualization Type: Select a visualization type that suits
your data and objectives. Common types include bar charts, line charts,
scatter plots, histograms, and pie charts.
 Prepare and Transform Data: Preprocess your data as needed. This may
involve aggregating, filtering, or transforming the data to fit the chosen
visualization.
 Create the Visualization: Use a suitable tool or library to create your
visualization. Customize it with labels, colors, and other design elements.
 Interactivity (Optional): If appropriate, add interactive features to your
visualization to allow users to interact with the data.
 Test and Iterate: Review your visualization for accuracy and clarity. Seek
feedback from others and make improvements as necessary.
 Publish or Share: Once you are satisfied with your visualization, publish it on
a platform, embed it in a report, or share it with your intended audience.
 Document and Explain: Provide context and explanations for your
visualization. Clearly communicate what the viewer should take away from it.
 Maintain and Update: If the data changes or new insights emerge, update
your visualization accordingly.

Aim:

Getting started with Tableau Software using Data file formats, connecting your
Data to Tableau, creating basic charts(line, bar charts, Tree maps),Using the
Show me panel.
Solution :

Getting started with Tableau software is a great way to create data visualizations
quickly and efficiently. Here are the steps to get started, including connecting your
data to Tableau, creating basic charts like line charts, bar charts, and treemaps, and
using the Show Me panel:

1. Download and Install Tableau:


First, you'll need to download and install Tableau Desktop or Tableau Public (a free
version). Follow the installation instructions provided on the Tableau website for
your specific operating system.

2. Prepare Your Data:

Before connecting your data to Tableau, ensure that your data is in a suitable format.
Common data file formats that Tableau supports include Excel (.xlsx), CSV (.csv),
and text files (.txt). Make sure your data is organized with headers for each column.

3. Connect Your Data to Tableau:

3.1 Launch Tableau Desktop.

3.2 Go to "File" Menu and then click on "Open".


3.3 Choose the data source type (e.g., Excel, CSV, text file) and Select the data
file(P6-SuperStoreUS-2015.xls) and click "Open".

3.4 Drag any table(e.g. Orders) into working area.

3.5 Click on Worksheet(Sheet1).


4. Data Source Pane:
Once your data is connected, the Data Source Pane will appear on the left-hand side
of the Tableau interface. Here, you can see a preview of your data and perform data
transformations or join multiple data sources if necessary.

5. Creating Basic Charts:


Now, let's create some basic charts using Tableau:
a. Line Chart:

1. From the "Data Source pane", drag and drop the date field to the Columns
shelf and a numeric field (e.g., sales, revenue) to the Rows shelf.

2. Then Tableau will automatically create a line chart. You can customize it by
adding labels, titles, and formatting.
b. Bar Chart:

1. Drag and drop a categorical field (e.g., product category, region) to the Columns
shelf and a numeric field to the Rows shelf.
2. Then Tableau will create a bar chart. You can adjust the orientation and
formatting as needed. To display Labels on the bars click on Lables and select "Show
mark lables"

c. Treemap:

1. Drag and drop a categorical field to the Columns shelf.


2. Drag and drop a numeric field to the Size shelf.
3. Tableau will create a treemap visualization. You can further customize it by
adjusting colors and labels.

6. Using the Show Me Panel:


The Show Me panel in Tableau helps you explore various chart types based on your
data and the fields you select. Here's how to use it:
1. After adding fields to the Rows and Columns shelves, click on the "Show Me" panel
located on the left side of the Tableau interface.
2. In the Show Me panel, you'll see a variety of chart options that Tableau
recommends based on your data. Click on a chart type to create it.
3. Tableau will automatically generate the selected chart type with your data. You
can further customize it as needed.
4. To go back to the regular worksheet view, click the "Clear" button in the Show Me
panel.
Aim:

Tableau Calculations, Overview of SUM, AVR, and Aggregate features,


Creating custom calculationsand fields

Solution :
Tableau offers a powerful set of calculation tools that allow you to manipulate,
transform, and analyze your data in various ways. Here's an overview of some key
concepts related to Tableau calculations, including SUM, AVG (average), and
aggregate functions, as well as creating custom calculations and fields

SUM and AVG (Average) Functions

SUM Function
The SUM function in Tableau calculates the total sum of a numeric field. You can
use it to find the sum of values in a column or as part of a more complex
calculation. To use SUM, simply drag and drop a numeric field into the "SUM" shelf,
or you can create a calculated field using the SUM function.
AVG (Average) Function
The AVG function calculates the average (mean) value of a numeric field. Like
SUM, you can use it by dragging a numeric field into the "AVG" shelf or creating a
calculated field with the AVG function.
Aggregate Functions:
Tableau provides a range of aggregate functions that allow you to perform
calculations on groups of data. Common aggregate functions include SUM, AVG,
COUNT, MIN (minimum value), and MAX (maximum value). These functions are
particularly useful when you want to analyze data at different levels of granularity
(e.g., by category, region, or time period).
Creating Custom Calculations
Tableau allows you to create custom calculations using calculated fields. Here's
how to create a custom calculation:

1. Create a New Calculated Field


In the Data Source Pane, right-click on your data source and select "Create
Calculated Field".
Alternatively, you can create a calculated field by right-clicking on a shelf in your
worksheet and choosing "Create Calculated Field".

2. Enter Your Calculation:


In the calculated field editor, you can use functions, operators, and field references
to define your calculation.
For example, you can create a calculated field to calculate profit margin as
(SUM([Profit]) / SUM([Sales])) * 100.

3. Name and Save the Calculated Field:


Give your calculated field a meaningful name.
Click the "OK" or "Apply" button to save the calculated field.
4. Use the Calculated Field in Your Worksheet:
You can now use the calculated field like any other field in your worksheet. Drag
it to the Rows or Columns shelf, use it in filters, or create visualizations based on
it.
Aim:

Applying new data calculations to your visualizations, Formatting


Visualizations, Formatting Tools and Menus, and Formatting specific
parts of the view.

Solution :

Applying New Data Calculations to Visualizations

1. Drag and Drop Calculated Fields:


To apply your newly created calculated fields to a visualization, simply drag and
drop them onto the appropriate shelves in your worksheet. For example, you can
drag a calculated field to the Rows or Columns shelf, use it in filters, or place it on
the Marks card to control the appearance of marks.

2. Filter with Calculated Fields:


Create filters using calculated fields to control which data points are displayed in
your visualization. You can use calculated fields to filter by specific criteria, such
as a calculated date range or a custom ranking.
Formatting Visualizations
Tableau provides a wide range of formatting options to make your visualizations
more appealing and informative:

1. Format Pane:
On the left side of the Tableau interface, you'll find the Format pane. It allows you
to format various aspects of your visualization, such as fonts, colors, lines,
shading, and borders. Simply select the element you want to format and use the
options in the Format pane to make changes.
2. Marks Card:
The Marks card, located above your visualization, offers formatting options specific
to the type of marks you're using (e.g., color, size, label). Click on the Marks card
to access these options and modify how your data is represented.
3. Axis and Gridlines:
You can format axis labels, titles, and gridlines to improve the readability of your
visualization. Right-click on an axis or gridline to access formatting options.
4. Legends and Color Scales:
Customize legends and color scales to provide context for your visualizations. You
can change colors, labels, and the position of legends to match your data.
Formatting Tools and Menus
Tableau provides several formatting tools and menus to help you refine the
appearance of your visualizations:

1. Format Menu:
The Format menu at the top of the Tableau interface provides access to various
formatting options, including font styles, shading, borders, alignment, and more.
You can use this menu to format text, labels, and other elements.
2. Worksheet Menu:
In the Worksheet menu, you'll find options to format the entire worksheet,
including background color, borders, and worksheet title. You can also adjust the
worksheet size.
3. Dashboard Menu:
If you're working with dashboards, the Dashboard menu allows you to format the
entire dashboard layout, including background, size, and title.
Formatting Specific Parts of the View
Tableau lets you format specific elements of your visualization:

1. Annotations:
You can add annotations to your visualizations to highlight important points or
provide additional context. Format these annotations using the options available
when you right-click on an annotation.
2. Tooltips:
Customize tooltips to display relevant information when users hover over data
points. You can format tooltips to show or hide specific fields and control their
appearance.
3. Headers and Titles:
Format headers, titles, and subtitles for clarity and consistency. Use the Format
pane or the Format menu to adjust text formatting, alignment, and shading.
Aim:

Editing and Formatting Axes, Manipulating Data in Tableau data, Pivoting


Tableau data.

Solution :

Editing and Formatting Axes:


1. Edit Axis Title:
 Click on the axis title you want to edit.
 You can now modify the title text, font, size, color, and alignment using the Format pane
or the toolbar at the top.
2. Edit Axis Labels:
 Right-click on an axis and select "Edit Axis."
 In the Edit Axis dialog box, you can change the formatting of labels, tick marks, and
other axis-related properties.

3. Scale and Range:


 To change the scale or range of an axis, right-click on it and select "Edit Axis."
 In the dialog box, adjust the Minimum and Maximum values, scale, or range according
to your needs.
Manipulating Data in Tableau data
Change Data Type
If Tableau has inferred a wrong data type for a column, the data type can be
changed by clicking on the data type symbol in the column header
New Column(Calculated Fields)
Calculated fields can be used if you need to create customized logic for
manipulating certain data types or data values. There are a large-range of
functions available in Tableau that can used individually or collectively for data
manipulation
Pivoting Tableau data
Data pivoting enables you to rearrange the columns and rows in a report so you
can view data from different perspectives

You might also like