Rstudio_tutorial

.pdf

School

Simon Fraser University *

*We aren’t endorsed by this school

Course

445

Subject

Computer Science

Date

Oct 30, 2023

Type

pdf

Pages

18

Uploaded by Sahajkaran21

BAMA 520 CUSTOMER ANALYTICS R and Rstudio tutorial Prepared for: BAMA 520 Customer Analytics Prepared by: Miremad Soleymanian and Neda Ahmadi September 8, 2022 Proposal number: Session 2
BAMA 520 SOFTWARE INSTALLATION Objective The software tools used with this book are written in R, a language and system for computational statistics. R is open source software, developed by a large, worldwide team of developers. The software consists of a base system and thousands of add-on packages. To assist in writing R code and developing analytics solutions, an Integrated Development Environment (IDE) is essential. The most common IDE for R is RStudio. In other words, RStudio is just an interface shell for the R programming. Therefore, we need install both R and RStudio before using them. 1- Downloading and Installing R Use link below and download the proper installation for your operating system(Windows/IOS/ Linux): https://cran.r-project.org/ Follow the instructions. Installing Rstudio without proper installation of R on your operating system will prevent you from having a functionable environment. 2- Downloading and Installing Rstudio Download the free version of Rstudio Desktop from (https://www.rstudio.com/products/ rstudio/). Follow intallation instructions.
BAMA 520 RSTUDIO ENVIRONMENT 1- Rstudio pannels An accessible introduction to RStudio for the total beginner. Includes basic treatment of the four primary panels and a few easy examples to help you get started using R with RStudio. - Source Panel Panel on the upper left is called the source panel. This is where you write and save your code scripts which is basically a text file. Saved code scripts give you the ability to rerun any part of the code you want and recreate your analysis and visualizations in case any changes occur in your original data. Source Panel Environment Panel Console and Terminal Panel File and plot Panel
- Console and Terminal Panel Panel on lower left. Console panel shows you the results of the code that you run in source panel. Also, you can directly run R codes in this panel in an interactive way. However, those codes will not be saved or cannot be used for future needs. Terminal will act as the terminal you have on your pc. You can move to different repositories, change location of directories and …. - Environment Panel Environment panel is located on upper right side. It will show you the outputs and variables you define during coding. Also, you can see the history od actions in your code and console by clicking on the history tab. - Plots and File Panel Files tab will show you the files located on you drive. You can change directories that a code is being run in and see the folders and files that you want to read or is being saved. Plots tab is where you can see the visualizations and plots which we will get familiar with as we move forward. CODING IN A NEW SCRIPT 1- Creating a New script You can create a new script by clicking on File-> New FIle -> R script or using the shortcut version written in front of it. This will create a new Rscript which you can start coding in. By trying to save the file(Ctrl S in windows and Command S in mac) you can define the location and name of the script to be able to use it for future needs. 1- Running Code in Rstudio Before moving to Basic coding skills let’s get familiar with how to run lines or the whole script in Rstudio.
If you look at upper section of Source panel you can find buttons shown in image below. In case you want to run few lines in your script, select those lines and click on Run button. But if you want to run the whole script, click on Source. You can also use Ctrl or Command Enter as a shortcut for Source to run the whole script. Once you use any of these methods you can see the executed lines in console. If you want to work with created variables interactively and understand it more use the console panel to show variable outputs or perform other operations such as mean,max,sum and …. Running your script will show you defined variable in environment panel. You can always clean the environment panel by clicking on the broom icon.
R TUTORIAL - SESSION 2 Before getting started with course materials let’s get to know a few basic commands which can help you throughout the process. Data Types R has a wide variety of data types including scalars, vectors (numerical, character, logical), matrices, data frames, and lists. We will get familiar with a few of these data types throughout the semester. Set up working directory Generally, when you execute an R script the initial directory that the code runs in is the same directory as your script file. This means you have a direct access to any folder or file in that directory. However, if you need to load or save any file outside that, you need provide the complete adress to that location. A way to go around this is assigning your working directory in Rstudio. Under the “Files Plots Packages Help Viewer” window, usually on the bottom right window ofRStudio, click “Files” tab if “Files” tab is not chosen. If “Files” tab is selected, browse to thelocation where you wish to store scripts and data. Last, click “More” button, which is just aboveyour course folder line, and select the option “Set As Working Directory”. You can also write the following code in your console panel. If you want to doble check the final working directory you can use getwd( ) command in console panel. Creating New Variables Use the assignment operator <- to create new variables. Image below shows a sample of how you can define a variable in R script or console.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: How do you rewrite the expression 4 logx — 3 log(x^2 + 1) + 2 log(x—1) as a single logarithm log A?
Q: Review Conceptual Example 2 before attempting this problem. The moon has a diameter of 3.48 x 106 m…
Q: RAB ΑΟ ΒΟ 6Ω 12 Ω Find the resistance at the terminals A-B in the network in Figure. 6Ω 12 Ω 60 6Ω •…
Q: For the Sine wave shown below, Figure 2: a. The peak-to-peak value is equal to: b. The peak value is…
Q: A standard may be used to design a file integrity monitoring system.
Q: ts decreased from $200,000 to $150,000 and variable cost per unit of $ 5 remained unchanged. How…
Q: 1- Here we have a practical grammar for generating four-function expressions as  below. Please…
Q: 2. Consider the curve y = (x²+2) ³¹/ 0≤x≤1 a) Find the length of this curve b) Find the volume of…
Q: Find the number of 3-digit integers that are not divisible by 4, 5, or 6.
Q: Part A: Find all values of x in the interval [0, 2π] that satisfy the equation. (Enter your answers…
Q: a) y = cos 2x on [0,1] b) x= on [1,10]
Q: According to the Mars company, packages of milk chocolate M&Ms contain 20% orange candies. Suppose a…
Q: 7. A manufacturer wants to design an open box (no top) having a square base and volume of 1/2 liter.…
Q: Convert the point (x, y, z) = ( − 2, – 1, 1) to cylindrical coordinates. Give answers as positive…
Q: Solve the initial value problems in Exercises 15–20. dy + 2y = 3, y(0) = 1 15. dt dy 16. t + 2y =…
Q: 2. Determine the arc length of the given curves a) x = 1/² + 1/ 4y luoda r b) y = ln (cos x) 1 ≤ y…
Q: Ques If 450 g of magnesium hydroxide is dissolved in water to make 6.5 L of solution, what is the…
Q: 4. Quarterly demand for smartphones at a retailer is as shown. After obtaining initial estimates for…
Q: Which of the following is an essential component of the definition of learning? Question 1…
Q: 2) Consider the following unbalanced net ionic redox equation. MoO42- + SO32- Mo2+ + SO4²- notorien…
Q: (a) Show that S is path-connected, by constructing for any two points x, y € Sn an explicit path…
Q: hat are the aims and purposes of the software for file integr