ps4_tonyzhang

.pdf

School

Pennsylvania State University *

*We aren’t endorsed by this school

Course

184

Subject

Computer Science

Date

Apr 3, 2024

Type

pdf

Pages

8

Uploaded by MajorMaskMule13

Report
Assignment Title Your Name Here Date Use Headers Use headers to organize your document. The first level heading is denoted by a single pound sign/hash tag, # . Each new problem/exercise should get a Level 1 Heading. For subparts, increase the heading level by increasing the number of hash tags. For example, if Problem 1 has Parts A (with parts i-ii) and B, your R Markdown file would have the following: # Problem 1 [text] ## Part A [text] ### Part i [text] ### Part ii [text] ## Part B [text] Code There are two ways to include code in your document: inline and chunks. Inline Code To add inline code, you’ll need to type a grave mark ‘ (the key to the left of the numeral 1 key), followed by a lower case r, a space, then the R commands you wish to r and a final grave. For example ‘ r nrow(dataFrame) ‘ would return the number of rows in the data frame named “dataFrame”. Inline code is good for calling values you have stored and doing quick calculations on those values. Inline code will not be added to the Code Appendix. Code Chunks For more complicated code such as data manipulation and cleaning, creating graphs or tables, model building and testing, you’ll want to use code chunks. You can do this in two ways: You can click the Insert button found just above the RStudio’s editor page (has an icon of a white circle with a green plus sign and a green square with a white C) and selecting R from the drop down list. You can create your own code chunk by typing three graves in a row, returning twice and typing three more graves. You should see the editor become shaded gray for those three lines. You will want to write your code starting in the middle blank line. In the first line, right after the third grave, you’ll want to set options including coding language and chunk name as well as other options (e.g., figure caption and dimensions). 1
Mathematics To type mathematical formulas, you will need to use LaTeX commands. For inline mathematics you’ll need to enclose your mathematical expression in \( and \). For display math (on it’s own line and centered), enclose the expression in \[ and \]. The following code will automatically create your Code Appendix by grabbing all of your code chunks and writing that code here. Take a moment to look through the appendix and make sure that your code is fully readable. Use comments in your code to help create markers for what code does what. 2
Code Appendix # This template file is based off of a template created by Alex Hayes # https://github.com/alexpghayes/rmarkdown_homework_template # Setting Document Options knitr :: opts_chunk $ set ( echo = TRUE , warning = FALSE , message = FALSE , fig.align = "center" ) install.packages ( "mdsr" , repos = "http://cran.us.r-project.org" ) install.packages ( "dplyr" , repos = "http://cran.us.r-project.org" ) library (mdsr) library (dplyr) data ( "Minneapolis2013" ) same_first_second <- Minneapolis2013 %>% filter (First == Second) num_same_first_second <- nrow (same_first_second) head (same_first_second) top_3_choices <- same_first_second %>% count (First) %>% arrange ( desc (n)) %>% head ( 3 ) top_3_choices ole_savior_first <- Minneapolis2013 %>% filter (First == "Ole Savior" ) top_3_second_choices <- ole_savior_first %>% count (Second) %>% arrange ( desc (n)) %>% head ( 3 ) print (top_3_second_choices) install.packages ( "ggplot2" , repos = "http://cran.us.r-project.org" ) library (ggplot2) data (diamonds) diamonds %>% group_by (color) %>% summarise ( avg_carat = mean (carat)) %>% arrange ( desc (avg_carat)) %>% head ( 1 ) diamonds %>% group_by (clarity) %>% summarise ( avg_table_per_carat = mean (table / carat)) %>% arrange ( desc (avg_table_per_carat)) %>% head ( 1 ) Minneapolis2013 <- Minneapolis2013 %>% group_by (First) %>% mutate ( name_count = n ()) %>% mutate ( First = if_else (name_count < 5000 , "minor" , First)) %>% select ( - name_count) head (Minneapolis2013) 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