Data Visualization and Exploration with R A Practical... (PDF) (2024)

Explore PDF

Download PDF

0 Comments

    Summary Data Visualization and Exploration with R A Practical Guide to Using R RStudio and Tidyverse for Data Visualization Exploration and Data Science Applications

    Page 1

    Page 2

    Data Visualization and Explorationwith RA practical guide to using R, RStudio, and Tidyverse for datavisualization, exploration, and data science applications.

    Page 3

    Eric Pimpler

    Page 4

    Introduction to Data Visualizationand Exploration with RA practical guide to using R, RStudio, and tidyverse for datavisualization, exploration, and data science applications.Eric PimplerGeospatial Training Services 215 W Bandera #114-104Boerne, TX 78006PH: 210-260-4992Email: [emailprotected] Web: http://geospatialtraining.com Twitter:@gistrainingCopyright © 2017 by Eric Pimpler – Geospatial Training Services All rightsreserved.No part of this book may be reproduced in any form or by any electronic ormechanical means, including information storage and retrieval systems, withoutwritten permission from the author, except for the use of brief quotations in abook review.

    Page 5

    About the AuthorEric PimplerEric Pimpler is the founder andowner of Geospatial Training Services (geospatialtraining.com) and have over25 years of experience implementing and teaching GIS solutions using Esrisoftware. Currently he focuses on data science applications with R along withArcGIS Pro and Desktop scripting with Python and the development of customArcGIS Enterprise (Server) and ArcGIS Online web and mobile applicationswith JavaScript.Eric is the also the author of several other books including Introduction toProgramming ArcGIS Pro with Python(https://www.amazon.com/dp/1979451079/re(https://www.amazon.com/dp/1979451079/re1&keywords=Programming+ArcGIS+Pro+with +Python), ProgrammingArcGIS with Python Cookbook (https://www.packtpub.com/ application-development/programmingarcgis-python-cookbook-second-edition), SpatialAnalytics with ArcGIS (https://www. packtpub.com/application-development/spatial-analytics-arcgis), Building Web and Mobile ArcGIS Server Applicationswith JavaScript (https://www.packtpub.com/ application-development/building-weband-mobile-arcgis-server-applicationsjavascript), and ArcGIS Blueprints(https:// www.packtpub.com/applicationdevelopment/arcgis-blueprints).

    Page 6

    If you need consulting assistance with your data science or GIS projets pleasecontact Eric at eric@geospatialtraining. com or [emailprotected].Geospatial Training Services provides contract application development andprogramming expertise for R, ArcGIS Pro, ArcGIS Desktop, ArcGIS Enterprise(Server), and ArcGIS Online using Python, .NET/ArcObjects, and JavaScript.

    Page 7

    Downloading and Installing Exercise Data for thisBookThis is intended as a hands-on exercise book and is designed to give you asmuch handson coding experience with R as possible. Many of the exercises inthis book require that you load data from a file-based data source such as a CSVfile. These files will need to be installed on your computer before continuingwith the exercises in this chapter as well as the rest of the book. Please followthe instructions below to download and install the exercise data1. In a web browser go to one of the links below to download the exercise data:https://www.dropbox.com/s/5p7j7nl8hgijsnx/IntroR.zip?dl=0.https://s3.amazonaws.com/VirtualGISClassroom/IntroR/IntroR.zip2. This will download a file called IntroR.zip.3. The exercise data can be unzipped to any location on your computer. Afterunzipping the IntroR.zip file you will have a folder structure that includes IntroRas the top-most folder with sub-folders called Data and Solutions. The Datafolder contains the data that will be used in the exercises in the book, while theSolutions folder contains solution files for the R script that you will write.RStudio can be used on Windows, Mac, or Linux so rather than specifying aspecific folder to place the data I will leave the installation location up to you.Just remember where you unzip the data because you’ll need to reference thelocation when you set the working directory.4. For reference purposes I have installed the data to the desktop of my Maccomputer under IntroR\Data. You will see this location referenced at variouslocations throughout the book. However, keep in mind that you can install thedata anywhere.

    Page 8

    Table of ContentsCHAPTER 1: Introduction to R and RStudio....................................................... 9Introduction to RStudio...........................................................................................................10Exercise 1: Creating variables and assigning data.............................................................27Exercise 2: Using vectors and factors....................................................................................32Exercise 3: Using lists.................................................................................................................36Exercise 4: Using data classes................................................................................................39Exercise 5: Looping statements..............................................................................................46Exercise 6: Decision support statements – if | else..............................................................48Exercise 7: Using functions......................................................................................................51Exercise 8: Introduction to tidyverse......................................................................................53CHAPTER 2: The Basics of Data Exploration and Visualization with R.......... 57Exercise 1: Installing and loading tidyverse..........................................................................58Exercise 2: Loading and examining adataset.....................................................................60Exercise 3: Filtering a dataset.................................................................................................64Exercise 4: Grouping and summarizing a dataset...............................................................65Exercise 5: Plotting a dataset.................................................................................................66Exercise 6: Graphing burglaries by month and year

    Page 9

    ...........................................................67CHAPTER 3: Loading Data into R...................................................................... 73Exercise 1: Loading a csv file with read.table()....................................................................73Exercise 2: Loading a csv file with read.csv().......................................................................76Exercise 3: Loading a tab delimited file with read.table()..................................................77Exercise 4: Using readr to load data.....................................................................................77CHAPTER 4: Transforming Data........................................................................ 83Exercise 1: Filtering records to create a subset....................................................................84Exercise 2: Narrowing the list of columns with select()........................................................87Exercise 3: Arranging Rows.....................................................................................................90Exercise 4: Adding Rows with mutate().................................................................................92Exercise 5: Summarizing and Grouping.................................................................................94Exercise 6: Piping......................................................................................................................97Exercise 7: Challenge..............................................................................................................99CHAPTER 5: Creating Tidy Data .....................................................................101Exercise 1: Gathering............................................................................................................102Exercise 2: Spreading............................................................................................................107

    Page 10

    Exercise 3: Separating...........................................................................................................110Exercise 4: Uniting..................................................................................................................113CHAPTER 6: Basic Data Exploration Techniques in R ...................................115Exercise 1: Measuring Categorical Variation with a Bar Chart........................................116Exercise 2: Measuring Continuous Variation with a Histogram.........................................118Exercise 3: Measuring Covariation with Box Plots..............................................................120Exercise 4: Measuring Covariation with Symbol Size.........................................................122Exercise 5: 2D bin and hex charts........................................................................................124Exercise 6: Generating Summary Statistics.........................................................................126CHAPTER 7: Basic Data Visualization Techniques ........................................129Step 1: Creating a scatterplot..............................................................................................130Step 2: Adding a regression line to the scatterplot...........................................................133Step 3: Plotting categories....................................................................................................136Step 4: Labeling the graph...................................................................................................137Step 5: Legend layouts..........................................................................................................144Step 6: Creating a facet.......................................................................................................146Step 7:Theming......................................................................................................................147Step 8: Creating bar charts

    Data Visualization and Exploration with R A Practical... (PDF) (2024)

    References

    Top Articles
    Latest Posts
    Article information

    Author: Ouida Strosin DO

    Last Updated:

    Views: 6307

    Rating: 4.6 / 5 (76 voted)

    Reviews: 91% of readers found this page helpful

    Author information

    Name: Ouida Strosin DO

    Birthday: 1995-04-27

    Address: Suite 927 930 Kilback Radial, Candidaville, TN 87795

    Phone: +8561498978366

    Job: Legacy Manufacturing Specialist

    Hobby: Singing, Mountain biking, Water sports, Water sports, Taxidermy, Polo, Pet

    Introduction: My name is Ouida Strosin DO, I am a precious, combative, spotless, modern, spotless, beautiful, precious person who loves writing and wants to share my knowledge and understanding with you.