Solutions_Assignment #1_Max 503



Illinois Institute Of Technology *

*We aren’t endorsed by this school




Computer Science


Feb 20, 2024





Uploaded by DukeFlagJaguar44 on

Max 503 Assignment #1 Instructions: Note 1: there may be many ways to solve a problem in R. As we progress, we will demonstrate progressively better ways to solve some of the same problems. R programmers may differ as to what constitutes “better.” Some may prefer elegance while others prefer speed or ease of comprehension. At this point, I recommend that you consider whether a solution seems optimal, but don’t worry too much about it. Getting a correct answer in any one of multiple possible ways is the most important outcome. Note 2: When an analysis includes more than a few simple steps, it becomes difficult to remember what you’ve done and even more difficult for others to understand it. In the worst case, you might perform analyses with undocumented console commands or out- of-sequence commands run from a code file. In that case, the code file doesn’t reflect the true sequence, and the results may be non-reproducible. If you run the code again, you may get a different answer because the steps are in a different order. Luckily, the R community has demonstrated leadership in addressing these issues and provided many powerful tools that can help. R Notebooks is one of those tools. R Notebooks Offered in RStudio, R Notebooks provide R Markdown live inside the RStudio environment. A notebook includes any text you want to write, along with R code and the *results* of R code. When you execute R code in a notebook, the results are shown inside your document. Here are a few tips: o You can create Section headers by using 1, 2, or 3 number signs (#) at the beginning of a line, followed by text. For example: #1 R code ………… #2 R code ………… (you follow the sequence like this) o You can format text with asterixes. Use *one for italic*, or **two for bold**. 1
Max 503 Assignment #1 o You can include R code by clicking the *Insert Chunk* button on the toolbar. Put your code between the lines with "```". A Basic R Notebook To create an R Notebook, launch RStudio Select File New File R Notebook The default R Notebook template will appear as an untitled document, as shown in the following figure: Note a few features of notebooks. At the top is a section with document settings, demarcated with three dashes, specifying the title (“R Notebook”, which you may edit ) and the targeted output format (HTML). Below that, there are two paragraphs of text, followed by an R code chunk with a gray background. 2
Max 503 Assignment #1 The R code chunk may contain any R commands, and they will be executed when the green “Run” (triangular) icon is clicked (or choose Code—Run Region—Run Current Chunk from the menu or shortcut keys). When we run the chunk in the default notebook, it plots the cars data set and shows the result inline in RStudio, as shown in the following figure : Inline plot shown in the notebook by clicking the green “Run current chunk” icon 3
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