Module #10: R and R Studio – The Basics

R and R Studio




Install R and R Studio. This is free and open source software. It is not large and doesn't tax the memory a lot. R runs on Windows, Mac and Linux, but this course is designed for the Mac version. If you use Windows, there may be variations in the lessons and instructions. Please see me for questions. Installing R is a two-step process: 1) Install R, the actual program 2) Install RStudio, a common interface 1) Download the most recent version of R for Mac:
https://mirrors.nics.utk.edu/cran/bin/macosx/R-4.0.2.pkg
--If you have a Windows computer, go to:
https://mirrors.nics.utk.edu/cran/bin/windows/base/R-4.0.2-win.exe
Accept all of the default settings for Mac. 2) Install RStudio, the interface we use to manage and create R code. Download the open source edition of R Studio desktop and follow the prompts to install it.
https://rstudio.com/products/rstudio/download/#download
Good instructions for installing R
http://www.machlis.com/R4Journalists/download-r-and-rstudio.html
Good overview of the program
https://docs.google.com/presentation/d/1O0eFLypJLP-PAC63Ghq2QURAnhFo6Dxc7nGt4y_l90s/edit#slide=id.p
Start Here
Basic tutorial on R:
https://profrobwells.github.io/Guest_Lectures/Intro_To_R/R1_Intro-to-R.html

Download the code and try it yourself
(Left click, download, remove.txt extension)
https://github.com/profrobwells/CovidFall2020/raw/master/Exercises/R1_Intro%20to%20R.Rmd


Reading
Machlis, Sharon. Practical R for Mass Communications and Journalism. Chapman & Hall/CRC The R Series. 2018. ISBN 9781138726918 https://www.amazon.com/gp/search?keywords=9781138726918 

Ch. 1, Introduction
Ch. 3, See How Much You Can Do in a Few Lines of Code 
Chapter 2: Get Started With R in a Few Easy Steps Here is the link to the firts six chapters for free
http://www.machlis.com/PracticalR4Journalism/index.html 


Advanced Corner
--Import Arkansascovid.com data and summarize Washington County trends
The master file
Ch 1 & 2 of Machlis: Key Points
Reproducible research Repetitive tasks in modern newsrooms. 
Employment reports, crime stats, budgets 

Variables - an R object 
Assignment operator <- Case sensitive 
Vector: A vector can only have one type of data - all integers, all strings 
Dataframe - like a spreadsheet 
Save files - Don’t save workspace: because all of your variables will be stored and re-loaded the next time you launch RStudio. 
It’s too easy to forget about previously stored variables that can interfere with later work,
Software packages: tidyverse, rio, pacman
Data Types and R
Machlis: 2.4.2 Data types you’re likely to use often
Reference: Logical Operators in R

Beginner’s guide to R: Introduction

https://www.computerworld.com/article/2497143/business-intelligence/business-intelligence-beginner-s-guide-to-r-introduction.html

RStudio IDE Easy Tricks You Might’ve Missed

https://rviews.rstudio.com/2016/11/11/easy-tricks-you-mightve-missed/

How Do I?

https://smach.github.io/R4JournalismBook/HowDoI.html

Packages

https://smach.github.io/R4JournalismBook/packages.html

 Download R and RStudio

http://www.machlis.com/R4Journalists/download-r-and-rstudio.html

You can download the most recent version of R at https://www.r-project.org/, which is the home of R (formally known as the R Project for Statistical Computing). The R-project home page usually includes information about the latest versions of R. Don’t be put off by the sometimes odd nicknames for R versions, such as “Very, Very Secure Dishes” and “Bug in Your Hair” – the software is much more useful than you might assume from the nicknames. (The whimsical version names come from various Peanuts cartoons.)

There should also be a prominent link to download R. Click that download option and you should be taken to CRAN, the Comprehensive R Archive Network, and a list of CRAN servers, called mirrors, around the world. Pick a server and choose the precompiled binary distribution for your operating system. Once the file finishes downloading, install it like any other software program – run the .exe for Windows or .pkg for Mac.

You should be fine accepting all the Mac defaults. On Windows, you’ll need to decide whether you want the 32- or 64-bit R version. (Unless you’ve got a pretty old system, chances are you’ll want 64-bit.)

This is all you need to start running R, but I strongly recommend also installing RStudio, a free platform designed to make it easier and more enjoyable to create and run R code. Head to RStudio.com and under products, look for RStudio and then RStudio Desktop (not Server), and download the free Open Source Edition version for your operating system. This, too, installs like a typical software program

Important Reference Materials
Data Structures in R-1wd5uem
Data Importing-t7pkq5
Importing CSVs-1w8mk8d
ggplot2-cheatsheet-19yp3zd