Outline Comparison of Excel and R R Coding Example – RStudio Environment – Getting Help – Enter Data – Calculate Mean – Basic Plots – Save a Coding Script
Brief Review of Excel Active Spreadsheet Area Most Everything is Point-and-Click
RStudio Active Coding Area Some Point-and-Click Place to Enter Single Commands View Some Output
Computing Average in Excel Range of Data Mathematical Formula
How to Find Average in R? STEPS Open a New Script Create a “Range” Vector in R Terminology Code is on the Website
Open up a New Script Window
Use the c() function to combine values or text In R a column is called a Vector ? to get more information ?c How to Create a “Range” in R?
How to Get Help on a Function ?c
Create the following Vector (i.e. Column of Data) x <- c(77, 60, 90) Why a “<-” and not an “=“ Both work. “<-” is traditional Why a “x” can be named most anything
RStudio Environment Run Or CTRL-Enter Variable shows up as being the environment Command is Ran in the Console Enter Code
Let’s Try Some Basic Statistical Functions mean(x) max(x)
R Built-In Packages
Let’s Try Some Graphical Functions #charts plot(x) barplot(x) pie(x)
Plots To Clear Console: CTRL-L Zoom or Export Page Back
Save a Script Current File Directory: getwd() If Needed, Set New Working Directory Session > Set Working Directory > Choose Directory To save script / code: File > Save As The File will have a.R filetype