My Final Project Template

Subtitle here if desired

Author

Zhongyu Zhou

Published

November 7, 2024

Introduction

[~ 200 words]

Clearly stated background and questions / hypotheses / problems being addressed. Sets up the analysis in an interesting and compelling way. Include figures if you like.

Materials and methods

[~ 200 words]

Narrative: Clear narrative description of the data sources and methods. Includes data from at least two sources that were integrated / merged in R.

Code: The code associated with the project is well organized and easy to follow. Demonstrates mastery of R graphics and functions.

Data: The underlying data are publicly accessible via the web and downloaded/accessed within the Rmd script. If you want to use your own data, you must make it available on a website (e.g. Figshare) so that others are able to re-run your code.

You can do bullets like this:

  • The first most important thing
  • The second most important thing
  • The third most important thing

You can do numbers like this:

  1. The first most important thing
  2. The second most important thing
  3. The third most important thing

See http://rmarkdown.rstudio.com/ for all the amazing things you can do.

Here’s my first code chunk.

x=3+4

Refer to output in your narrative like this: x=7 .

Load any required packages in a code chunk (you may need to install some packages):

library(tidyverse)
library(leaflet)
library(kableExtra)
library(htmlwidgets)
library(widgetframe)
knitr::opts_chunk$set(widgetframe_widgets_dir = 'widgets' ) 
knitr::opts_chunk$set(cache=TRUE)  # cache the results for quick compiling

Download and clean all required data

n=20
data=data.frame(x=runif(n,-180,180),
                y=runif(n,-60,60),
                size = runif(n, 5, 20),
                category = factor(
                  sample(letters[1:5], n, replace = TRUE)
                  ),
                value = rnorm(n))
data %>% 
  slice(1:10) %>% #show only 1:n rows
  kable(digits=2,align="c")%>% #make table and round to two digits
  kable_styling(bootstrap_options = 
                  c("striped", "hover", "condensed", "responsive")) #apply other formatting
x y size category value
107.85 -56.87 16.68 e -0.40
-67.54 57.24 12.57 a 0.50
-177.42 -22.66 9.32 d -1.83
-87.31 -1.24 14.32 a -0.35
-171.29 33.16 14.79 b 0.24
159.30 -52.51 17.98 c -2.64
83.69 -13.87 17.45 c 0.14
-101.35 25.11 6.53 a 0.66
-5.27 -4.29 13.89 e 0.41
-161.34 32.47 15.13 e -0.21

Add any additional processing steps here.

Results

[~200 words]

Tables and figures (maps and other graphics) are carefully planned to convey the results of your analysis. Intense exploration and evidence of many trials and failures. The author looked at the data in many different ways before coming to the final presentation of the data.

Show tables, plots, etc. and describe them.

m <- leaflet(data) %>% 
  addTiles() %>% 
  addCircleMarkers(~x, ~y, radius = ~size,color = ~as.factor(category)) %>% 
  addPopups(~x[2], ~y[2], "Random popup")
m  # a map with the default OSM tile layer

Map of completely random data

data %>% 
  ggplot(aes(x=x,y=y,col=category))+
  geom_point()

Dygraphs Example

library(dygraphs)
dygraph(nhtemp, main = "New Haven Temperatures") |> 
  dyRangeSelector(dateWindow = c("1920-01-01", "1960-01-01")) 

Conclusions

[~200 words]

Clear summary adequately describing the results and putting them in context. Discussion of further questions and ways to continue investigation.

References

All sources are cited in a consistent manner