Chapter 1 Preface

Welcome to R and Python for SAS Programmers (RP2SAS). I hope that this book is helpful to you all. This is largely collection of different materials that are already available but collected at one place for my personnel reading.

1.1 Who This Book is For

This is a book for anyone in the clinical/medical field interested in analyzing the data available to them to better understand health, disease, or the delivery of care.

I expect that most learners will be using this book in their spare time at night and on weekends, as the SAS programmers are already packed full of information, and there is no room to add skills in reproducible research to the standard curriculum. This book is designed for self-teaching, and many hints and solutions will be provided to avoid roadblocks and frustration. Many learners find themselves wanting to develop reproducible research skills after they have finished their training, and after they have become comfortable with their clinical role. This is the time when they identify and want to address problems faced by patients in their practice with the data they have before them. This book is for you.

1.2 Prerequisites

Thank you for giving this e-book a try. This is designed for physicians and others analyzing health data who are interested in pursuing this field using the R computer language.
We will assume that:

  • You have access to a computer
  • You have access to the internet
  • You can download and install software from the internet to your computer


1.3 The Spiral of Success Structure

This book is structured on the concept of a “spiral of success”, with readers learning about topics like data visualization, data wrangling, data modeling, reproducible research, and communication of results in repeated passes. These will initially be at a superficial level, and at each pass of the spiral, will provide increasing depth and complexity. This means that the chapters on data wrangling will not all be together, nor the chapters on data visualization. My goal is to build skills gradually, and return to their previously built skills in one area and to add to them. The eventual goal is of this book to be able to produce, document, and communicate reproducible research to their community. Things that are done using one software (SAS) reproduce them in R and Python ( would add them later)

1.4 Motivation for this Book

Great book written by Peter D.R. Higgins ( Reproducible Medical Research with R RMRWR ).

Most SAS programmers who learn R to do their own data analysis do it on their own time.

They rarely have time for a semester-long course, as their clinical schedules usually will not allow it. Fortunately, a lot of people learn R on their own, and there is a strong and supportive R community to help new learners.

A 2019 Twitter survey conducted by @RLadies found that more than half of respondents were largely self-taught, from books and online resources.

There are a lot of good resources for learning R, so why one more?

In part, because the needs of a SAS Programmers are often different.

Further, while learning from a textbook can be helpful, this e-book has the ability to include interactive features that are important for learning to write your own analysis code.

Informative flipbook demonstrations will show you what steps in R code do, and learnr exercises will give you a chance to do your own coding to solve problems, right within this e-book.

1.5 Features of a Bookdown electronic book

1.5.1 Icons

There are several icons at the top left, to the right of the clickable RP2SAS link, that can be helpful:

1. The Table of Contents Sidebar - Click on the ‘hamburger’ menu icon (three horizontal lines) or the s key to toggle the sidebar (table of contents) on and off.

Within the sidebar, you can click on whichever chapter or subsection you want.

2. This book is Searchable - Click on the magnifying glass or use the f key to toggle the Find box and search for whatever you need to find.

3. You can change the font size, font, and background by clicking on the A icon.

4. You can download the chapter with the download icon (downward arrow into a file tray) in PDF or EPUB formats.

1.5.2 Sharing

At the top right, there are several icons for sharing links to the current chapter through social media.

1.5.3 Scrolling/Paging

  1. You can scroll up and down within a chapter with your mouse, or use the up and down arrow keys.
  2. You can page through chapters with the left and right arrow keys.

1.6 What this Book is Not

1.6.1 This Book is Not A Statistics Text

This is not an introduction to statistics. This is not a SAS or R or Python programming book .

I am assuming that you have SAS programming experience and willing to learn other programming language.

There are lot of resources out there to teach you SAS or R programming individually.

If you need to brush up on your statistics, no worries.

There are several excellent (and free!) e-books on that very topic, using R. Some good examples include (go ahead and click through the blue links to explore):

  1. Learning Statistics with R (LSR)
  2. Open Intro Statistics
  3. Modern Dive
  4. Teacup Giraffes

I will focus on specific medical examples, and emphasize issues (like Protected Health Information) that are particularly important for clinical data.

I am assuming that you are here because you want to analyze your own data in your study very limited free time.

1.6.2 This Book Does Not Provide Comprehensive Coverage of the SAS or R Universe

This book is also far from comprehensive in teaching what is available in the R ecosystem.

This book should be considered a launch pad for crossing over from SAS to R programming.

Many of the later chapters will give you a taste of what is available in certain areas, and guide you to resources (and links) that you can explore to learn more and do more beyond the scope of this book.

The R computer language has expanded far beyond statistics, and allows you to do many powerful things to improve your workflow, make amazing graphics, and share results with others.

1.7 Some Guideposts

Keep an eye out for helpful Guideposts, which look like this:

Warnings

This is a common syntax error, especially for beginners. Watch out for this.

Tips

This is a helpful tip for debugging.

Try It Out

Take what you have learned and try it yourself on your own computer.

Challenge - take the next step and try a more challenging example.

Try this more complicated example.

Explore More - resources for learning more about a particular topic.

If you want to learn more about Shiny apps, go to https://mastering-shiny.org to see an entire book on the topic.

1.8 Helpful Tools

Throughout this book you will find flipbook code demonstrations and learnr code interactive exercises in which you can practice writing R code right in the book. Let’s explain how to use these demonstration flipbooks and learnr exercises.

1.8.1 Demonstrations in Flipbooks

Flipbooks are windows in this book in which you can watch R code being built into pipelines, and see the results at each step. Each flipbook demonstrates some important code concepts, and often new functions in R. You can click on the window to activate it, and the fullscreen (4 arrows) icon to expand it to the full screen. Then use the left and right arrow keys to go forward and back in the code, one step at a time. You will want to go through these slowly, and make sure that you understand what is happening in each step. You may even want to take notes, particularly on the function syntax, as you will likely coding exercises with these functions shortly after the flipbook demonstration.

Take a look at the example of a flipbook below.
Activate it by clicking on it, and use the expand icon (4 arrows at the lower right) to make it full screen. You can step forward and backward through the pipeline of code with the right and left arrow keys. Watch the results of each step.

[Flipbook Demo] : (https://flipbookdemo.netlify.app)