Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aa #4

Closed
wants to merge 100 commits into from
Closed

aa #4

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
7b71ecf
intro to spatial analysis vignette
mitchellmanware Oct 25, 2023
c977f56
add 10-intro_spatial_analysis.qmd
mitchellmanware Oct 26, 2023
8e4919b
add 10-intro_spatial_analaysis.qmd to _bookdown.yml
mitchellmanware Oct 26, 2023
931d151
use variable for working directory
mitchellmanware Oct 30, 2023
21473f6
re-style with styler::
mitchellmanware Oct 30, 2023
bbab4fe
1.0 Point Data- added unit tests
mitchellmanware Oct 30, 2023
ebda0e0
2.1. Polygon data with sf- unit tests
mitchellmanware Oct 30, 2023
8efcd41
adhere to lintr styles
mitchellmanware Oct 30, 2023
d3f2b8b
3.0 Raster Data with terra- unit testing
mitchellmanware Oct 30, 2023
c299e9e
correct misspellings
mitchellmanware Oct 30, 2023
5cfde2e
1.0 Point Data- refine text
mitchellmanware Nov 6, 2023
dfd55b2
2.1 Point Data with sf- refine text
mitchellmanware Nov 7, 2023
3ef2c2a
2.2 Polygon Data with terra- refine text
mitchellmanware Nov 7, 2023
8cd797a
3.0 Raster Data with terra- refine text
mitchellmanware Nov 7, 2023
123806e
consistent reference to United States' state boundaries
mitchellmanware Nov 7, 2023
edf101c
update unit tests
mitchellmanware Nov 7, 2023
cdcf1ea
add user profiles
mitchellmanware Nov 13, 2023
e3ca43f
render to pdf
mitchellmanware Nov 13, 2023
1d497d3
render to html
mitchellmanware Nov 17, 2023
59b82fe
convert to Rmarkdown
mitchellmanware Nov 20, 2023
136e831
re-format numbering
mitchellmanware Nov 20, 2023
9a9b882
reformat numbers 2; add callout note boxes
mitchellmanware Nov 20, 2023
704353c
custom :::callout-note boxes
mitchellmanware Nov 20, 2023
1496253
callout boxes
mitchellmanware Nov 20, 2023
9ecc1b5
change from Quarto to Rmarkdown
mitchellmanware Jan 11, 2024
5316c14
update manware_1025 branch
mitchellmanware Jan 11, 2024
e1b5e35
simplify user profiles
mitchellmanware Jan 11, 2024
2bfce6a
data download function vignette
mitchellmanware Jan 16, 2024
c1dfa4d
chmod 0600 .netrc
mitchellmanware Jan 16, 2024
62ef586
remove NASA EarthData chapter
mitchellmanware Jan 24, 2024
855f75c
comment for educational purposes only
mitchellmanware Jan 30, 2024
3c1b16f
disable unit tests
mitchellmanware Jan 30, 2024
c2a8978
lintr workflow
mitchellmanware Jan 31, 2024
9e3956e
undo lint workflow
mitchellmanware Jan 31, 2024
f030b4f
disable live code
mitchellmanware Feb 1, 2024
7904d70
update branch
mitchellmanware Feb 1, 2024
d3c04a8
warning and important callout boxes
mitchellmanware Feb 1, 2024
0b39d4a
import images for plots; HTML formatting
mitchellmanware Feb 1, 2024
8560072
lintr workflow
mitchellmanware Feb 1, 2024
291d266
branch specific check
mitchellmanware Feb 1, 2024
b404fd7
lintr name
mitchellmanware Feb 1, 2024
ff4607e
superlintr
mitchellmanware Feb 1, 2024
37367e8
rename workflow files
mitchellmanware Feb 1, 2024
1c2e861
move lint workflow to new dev branch
mitchellmanware Feb 1, 2024
4ca9975
lint and styler
mitchellmanware Feb 1, 2024
d776609
super lint workflow
mitchellmanware Feb 1, 2024
bd736cb
run on push
mitchellmanware Feb 1, 2024
5673df3
lint 01-ma_pm_patient.Rmd
mitchellmanware Feb 1, 2024
26f3184
lint style.css 1
mitchellmanware Feb 1, 2024
a66180d
lint style.css 2
mitchellmanware Feb 1, 2024
bd9474d
lint style.css 3
mitchellmanware Feb 1, 2024
6fd4407
lint chapters (skip 09-tutorial-link-point-to-census-geoid.Rmd
mitchellmanware Feb 1, 2024
d819ce3
lint 05-bivariate_pm_patient.Rmd
mitchellmanware Feb 1, 2024
56ccefc
update actions version
mitchellmanware Feb 1, 2024
e11f8bd
README.md header
mitchellmanware Feb 1, 2024
56ea433
README.md header 2
mitchellmanware Feb 1, 2024
325ec9a
README.md header 3
mitchellmanware Feb 1, 2024
181b88d
README.md header 4
mitchellmanware Feb 1, 2024
509cab2
README.md header 5
mitchellmanware Feb 1, 2024
505f818
skip MD041 linter
mitchellmanware Feb 1, 2024
1d4a4f9
empty header
mitchellmanware Feb 1, 2024
d80cb1a
badge under header
mitchellmanware Feb 1, 2024
d97c1d2
header fix
mitchellmanware Feb 1, 2024
0aedd5f
user profile tags; more linting
mitchellmanware Feb 2, 2024
c01dc67
bookdown workflow
mitchellmanware Feb 2, 2024
62b4795
bookdown workflow 2
mitchellmanware Feb 2, 2024
1f920dc
render with main.Rmd
mitchellmanware Feb 2, 2024
89d9209
remove renv step
mitchellmanware Feb 2, 2024
c25bd3d
bookdown dependency
mitchellmanware Feb 2, 2024
6866ea7
remove bookdown workflow
mitchellmanware Feb 2, 2024
47c7e57
bookdown render test workflow
mitchellmanware Feb 5, 2024
c19c48b
bookdown render test 2
mitchellmanware Feb 5, 2024
0fbbccd
bookdown render test 3
mitchellmanware Feb 5, 2024
26fb791
bookdown render test 4
mitchellmanware Feb 5, 2024
095c41c
DESCRIPTION file
mitchellmanware Feb 5, 2024
efef2bd
bookdown render test 5
mitchellmanware Feb 5, 2024
845925b
bookdown render test 6
mitchellmanware Feb 5, 2024
bef4890
bookdown render test 7
mitchellmanware Feb 5, 2024
a858c79
bookdown render test 8
mitchellmanware Feb 5, 2024
190a734
bookdown render test 9
mitchellmanware Feb 5, 2024
eb6f74f
bookdown render test 10
mitchellmanware Feb 5, 2024
cf432e9
tmap package fix 1
mitchellmanware Feb 5, 2024
d641c7c
tmap package fix 2
mitchellmanware Feb 5, 2024
43b5998
tmap package fix 2
mitchellmanware Feb 6, 2024
e7444d2
tmap package fix 3
mitchellmanware Feb 6, 2024
54395f5
tmap package fix 4
mitchellmanware Feb 6, 2024
7445c90
tmap package fix 5
mitchellmanware Feb 6, 2024
111bf3e
test_that within .yml file
mitchellmanware Feb 6, 2024
1bf02be
tmap package fix 6
mitchellmanware Feb 6, 2024
2ec0aca
disable bookdown workflow
mitchellmanware Feb 6, 2024
8f5a631
update README.md
mitchellmanware Feb 6, 2024
3b4bd6f
remove bookdown workflow; reset 08-PCOR-* chapters
mitchellmanware Feb 6, 2024
2b49594
user profiles
mitchellmanware Feb 6, 2024
e174099
exclude user profiles from table of contents
mitchellmanware Feb 6, 2024
d59ddb8
NASA EarthData account; robust user profiles page
mitchellmanware Feb 7, 2024
de47cb1
more linting
mitchellmanware Feb 7, 2024
4a7a5b0
remove tests/
mitchellmanware Feb 7, 2024
67fc283
Merge pull request #2 from NIEHS/mm_workflows
mitchellmanware Feb 7, 2024
548fa2c
Update README.md
mitchellmanware Feb 7, 2024
8401d1f
Update README.md
mitchellmanware Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/superlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Super Linter

on:
push:
pull_request:
branches: [main, master]

jobs:
super-lint:
name: Lint all file types
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Run Super-Linter
uses: github/super-linter@v4
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ shap_files/
_book/
_bookdown_files/
>>>>>>> 8352a4c7bb0838130d5237328968a4be46f37005

._11-intro*
11-intro_spatial_analysis_files/
images/user_profiles/
11-intro_spatial_analysis.tex
11-intro_spatial_analysis.html
3 changes: 0 additions & 3 deletions 00-setup.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ install.packages("styler")
### Rmarkdown

```{R car}

summary(cars)
```

Expand All @@ -16,6 +15,4 @@ summary(cars)
You can label code chunks with hyphens but we don't recommend using underscores or spaces. Think "kebabs, not snakes".

```{R plot}


```
103 changes: 54 additions & 49 deletions 01-ma_pm_patient.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,36 @@ The output file will contain one row per day between start_date and end_date for

```{R}
library(readr)
df <- read_csv("./dataset/ms_patient_pm_census_v2.csv",show_col_types = FALSE)

df <- read_csv("./dataset/ms_patient_pm_census_v2.csv", show_col_types = FALSE)
```

```{r}
dim(df)
colnames(df)

```


install packages

```{r}
if(!require('shiny') || !require('tidycensus') || !require('tidyverse') || !require('viridis')) {
install.packages(c("shiny","tidycensus","tidyverse","viridis"))

if (!require("shiny") ||
!require("tidycensus") ||
!require("tidyverse") ||
!require("viridis")) {
install.packages(c("shiny", "tidycensus", "tidyverse", "viridis"))
}
if(!require('plotly')){
if (!require("plotly")) {
install.packages("plotly", type = "source")
}

```

```{r }
if(!require('ggplot2')) {
install.packages('ggplot2')
if (!require("ggplot2")) {
install.packages("ggplot2")
}
if(!require('maps') || !require('ggmap')) {
install.packages(c("maps","ggmap"))
if (!require("maps") || !require("ggmap")) {
install.packages(c("maps", "ggmap"))
}

```
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Expand All @@ -86,10 +84,12 @@ library(tidyverse)
library(viridis)
library(shiny)
library(plotly)
#Only load the census key at the first time. then we set install=true
#census_api_key( install=TRUE)
# Only load the census key at the first time. then we set install=true
first <- FALSE
if (first == TRUE) {
census_api_key(install = TRUE)
}
options(tigris_use_cache = TRUE)

```

Data wrangling
Expand All @@ -99,65 +99,65 @@ Data wrangling
sum(is.na(df))

# If there are missing values, you can drop or fill them as per your requirement
df <- na.omit(df) # Drop rows with missing values

df <- na.omit(df) # Drop rows with missing values
```

Change column name for later map

```{r}
colnames(df)[which(names(df) == "lon")] <- "longitude"
colnames(df)[which(names(df) =="lat")] <- "latitude"
colnames(df)[which(names(df) == "lat")] <- "latitude"
dim(df)
```

Filter the rows based on the date range Use the subset() function to filter the rows based on the date range:2010 -2017to match 5 year sensus data

```{r}
filtered_df <- subset(df, date >= as.Date("2012-01-01") & date <= as.Date("2017-09-01"))
filtered_df <-
subset(df, date >= as.Date("2012-01-01") & date <= as.Date("2017-09-01"))
dim(filtered_df)

write.csv(filtered_df,"./dataset/asthma_small.csv")

write.csv(filtered_df, "./dataset/asthma_small.csv")
```

Combine information for display in tooltip

```{r}
# Combine the required information for hover tooltip into a new column
filtered_df$tooltip <- paste("PM2.5:", filtered_df$pm_pred, "<br>",
"Hospital Date:", filtered_df$date, "<br>",
"Patient Info:", filtered_df$code_display, "<br>",
"gender :", filtered_df$gender)

filtered_df$tooltip <- paste(
"PM2.5:", filtered_df$pm_pred, "<br>",
"Hospital Date:", filtered_df$date, "<br>",
"Patient Info:", filtered_df$code_display, "<br>",
"gender :", filtered_df$gender
)
```

### Create a Geographical Map

Load the required libraries for plotting maps:

```{r }
library(ggplot2)
library(maps)
library(ggmap)
library(ggplot2)
library(maps)
library(ggmap)
```

Add map data to the base plot using the map_data() function:

```{R}
# Draw massachusetts map
# Draw massachusetts map
ma_map <- map_data("state", region = "massachusetts")

# Create a base plot for Massachusetts
p <- ggplot() +
geom_polygon(data = ma_map, aes(x = long, y = lat, group = group),
fill = "lightgray", color = "black")

geom_polygon(
data = ma_map, aes(x = long, y = lat, group = group),
fill = "lightgray", color = "black"
)
```

```{R include=FALSE}
#print(p)

# print(p)
```

### Plotting the Data Points
Expand All @@ -167,25 +167,30 @@ Plot the data points on the map using the geom_point() function. Specify the lon
Add PM2.5 data points with hover information

```{r}
p <- p + geom_point(data = filtered_df, aes(x = longitude, y = latitude, color = pm_pred,
text = tooltip), size = 3)
#you can run this block code on your local to have mouse hover text. for Now it cannot
#rander on R-studio connect
#Convert the plot to a plotly object
# p <- ggplotly(p) %>%
# layout(hoverlabel = list(bgcolor = "white"),
# hovertemplate = paste(
# "<b>%{text}</b>"
# )
# )

p <- p + geom_point(data = filtered_df, aes(
x = longitude, y = latitude, color = pm_pred,
text = tooltip
), size = 3)
# you can run this block code on your local to have mouse hover text.
# for Now it cannot
# rander on R-studio connect
# Convert the plot to a plotly object
run <- FALSE
if (run == TRUE) {
p <- ggplotly(p) %>%
layout(
hoverlabel = list(bgcolor = "white"),
hovertemplate = paste(
"<b>%{text}</b>"
)
)
}
```

Draw the map

```{r}
print(p)

```


Loading