Book Image

Statistical Analysis with R

By : John M. Quick
Book Image

Statistical Analysis with R

By: John M. Quick

Overview of this book

<p>R is a data analysis tool, graphical environment, and programming language. Without any prior experience in programming or statistical software, this book will help you quickly become a knowledgeable user of R. Now is the time to take control of your data and start producing superior statistical analysis with R.<br /><br />This book will take you on a journey as the strategist for an ancient Chinese kingdom. Along the way, you will learn how to use R to arrive at practical solutions and how to effectively communicate your results. Ultimately, the fate of the kingdom depends on your ability to make informed, data-driven decisions with R.<br /><br />You have unexpectedly been thrust into the role of lead strategist for the kingdom. After you install your predecessor's mysterious data analysis tool, you will begin to explore its fundamental elements. Next, you will use R to import and organize your data. Then, you will use functions and statistical analysis to arrive at potential courses of action. Subsequently, you will design your own functions to assess the practical impacts of your predictions. Lastly, you will focus on communicating your results through the use of charts, plots, graphs, and custom built visualizations. The fate of the kingdom is in your hands. Your rapid development as a master R strategist is the key to future success.</p>
Table of Contents (17 chapters)
Statistical Analysis with R Beginner's Guide
Credits
About the Author
About the Reviewers
Preface
Index

Time for action – customizing a bar chart


To begin, we will expand our Chapter 8 bar chart using arguments specifically designed for the barplot(...) function. We will also become familiar with two different types of bar charts.

  1. Open R and set your working directory:

    > #set the R working directory
    > #replace the sample location with one that is relevant to you
    > setwd("/Users/johnmquick/rBeginnersGuide/")
  2. Load the Chapter 9 workspace. It contains the necessary information for this chapter:

    > #load the chapter 9 workspace
    > load("rBeginnersGuide_Ch_09_ReadersCopy.RData")
  3. Use the names, width, and space arguments to customize a chart's bars:

    > #modify the chapter 8 bar chart that compared the mean durations of the battle methods
    > #use the names argument to assign a text label to each bar
    > #the names argument receives a vector containing text labels for each of the chart's bars
    > barAllMethodsDurationNames <- c("Fire", "Ambush", 
    "Head to Head", "Surround")
    > ...