CS代考 DSME5110F)

Week 1 Summary (DSME5110F)
Getting familar with R and RStudio
After installing R and RStudio, the question is now how to start using R/RStudio. In this article, I’ll describe how to run RStudio.
Note that, it’s possible to use R outside or inside RStudio. However, I highly recommend to use R inside RStudio. RStudio allows users to run R in a more user-friendly environment.

Copyright By PowCoder代写 加微信 powcoder

Attentions
In the path to folders 1) where you install R and 2) the working directory (will introduce in the following lectures), do not include space or Chinese characters. Otherwise, you may not be able to load the datasets appropriately. If your user name on your computer includes a space or Chinese characters, please create a new user on your computer and then use the new user.
To check if the path to the default working directory includes a space or a Chinese character, type getwd() in the RStudio console and the press Enter.
Use R inside RStudio
Launch RStudio under Windows and macOS. RStudio screen:
Figure 1: RStudio
RStudio is a four pane work-space for 1) creating file containing R script, 2) typing R commands, 3) viewing command histories, 4) viewing plots and more.
1. Top-left pane: Code editor allowing you to create and open a file containing R script. The R script is where you keep a record of your work. R script can be created as follow: File –> New –> R Script.
2. Bottom-left pane: R console for typing R commands 3. Top-right pane:

• Workspace tab: shows the list of R objects you created during your R session
• History tab: shows the history of all previous commands 4. Bottom-right pane:
• Files tab: show files in your working directory (will learn)
• Plots tab: show the history of plots you created. From this tab, you can export a plot to a PDF
or an image files
• Packages tab: show external R packages available on your system. If checked, the package is
loaded in R.
Shortcut keys
• Ctrl (for Mac: Command) + Enter: run the current line (or the selections) and go to the next line (Select a few sentences and then Control + Enter). Others (not recommend):
– Alt (for Mac: Option) + Enter: run the current line/ (or the selections) and retain cursor position – Ctrl + Alt (for Mac: Command + Option) + R: run all in the current script
• Use Ctrl with – (for Mac: Command with -) to get <- Help • ? is equivalent to help(): give you the exact function • ?? is equivalent to help.search(): give you a list of candidates Packages and functions • Need to install the package (just install it once and no need to install it again in the future). Three equivalent ways: – install.packages("package_name") – Tools->Install Packages
– In Packages (bottom-right pane), click Install
• Each time you use functions in a package, you need to load the package. Two equivalent ways:
– library(package_name)
– tick the package in the list of packages
Data Structures
Three steps to learn a data structure: creating, indexing (will learn), and operations (will learn):
– creating: c(), seq, rep; logical (>, !, . . . ) – …
Close your R/RStudio session
Each time you close R/RStudio, you will be asked whether you want to save the data from your R session. If you decide to save, the data will be available in future R sessions.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com