-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackage Vignette.Rmd
67 lines (53 loc) · 4.91 KB
/
Package Vignette.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
title: "Package Vignette"
output: html_document
---
#Overview of Package
This package provides tools to help visualize epidemiologic data. The mapping functions allow users to visualize the prevalence of their variable of interest at the national and regional levels. The graph functions allow users to plot and visualize their data in many ways.
#Data Format
*The dataset must have variables for year and specific state. The state variable must be called "state_full" and have the full name of the state in all lower case letters. Some data cleaning may be needed for the function to run properly. Information on data cleaning is available through the link below:
https://stackoverflow.com/questions/7531868/how-to-rename-a-single-column-in-a-data-frame
#Mapping National Prevalence
##This function maps national prevalence of a variable of choice across all time points of the dataset.
Function: map_national_prevalence(data,existing_cases,population, state, year)
##Arguments:
data: dataset of choice formatted as specified
existing cases: variable for prevalence calculation
population: variable for population estimate
state: state arugment must be "state_full"
year: year argument must be "year"
*Example code:
map_national_prevalence(Fatalities_clean,existing_cases= "fatal",population="pop", state="state", year="year")
#Mapping Regional Prevalence
##This function maps regional prevalence of a variable of choice across all time points of the dataset. For user convenience, this package uses regional functions to map prevalence. The regions are: Northeast, South, Midwest and West.
Northeast includes: Massachusetts, Rhode Island, Connecticut, Maine, Vermont, New Hampshire, New York, New Jersey, and Pennsylvania
South includes: Delaware, Maryland, West Virginia, Virginia, Kentucky, Tennessee, North Carolina, South Carolina, Georgia, Alabama, Mississippi, Arkansas, Louisiana, Florida, Texas, and Oklahoma
Midwest includes: Ohio, Michigan, Indiana, Wisconsin, Illinois, Minnesota, Iowa, Missouri, North Dakota, South Dakota, Nebraska, and Kansas
South includes: Montana, Wyoming, Colorado, New Mexico, Arizona, Utah, California, Idaho, Nevada, Oregon, Washington, Hawaii, and Alaska
Function: map_northeast_prevalence(data,existing_cases,population, state, year)
Function: map_south_prevalence(data,existing_cases,population, state, year)
Function: map_midwest_prevalence(data,existing_cases,population, state, year)
Function: map_west_prevalence(data,existing_cases,population, state, year)
##Arguments:
data: dataset of choice formatted as specified
existing cases: variable for prevalence calculation
population: variable for population estimate
state: state arugment must be "state_full"
year: year argument must be "year"
*Example code:
map_national_prevalence(Fatalities_clean,existing_cases= "fatal",population="pop", state="state", year="year")
#Visualizing Data through plots
##1. Must have cleaned data with no NAs (Reference link: https://stackoverflow.com/questions/4862178/remove-rows-with-all-or-some-nas-missing-values-in-data-frame )
##2. Epiplot function arguments: (data, x, y, graph, fill, title, xlab, ylab, legend)
##3. Graphs: bar plot ("bar"), grouped bar plot ("bargroup"), stacked bar plot ("barstack"), box plot ("boxplot"), box plot with correlating dots ("dotboxplot"), histogram ("hist"), density plot ("densityhist"), scatter plot ("scatter"), scatter plot with correlating line ("scatterline"), linear regression ("linreg").
##4. Input the correct arguments:
###bar plot: (data=data, x=data$x, graph="bar", title="Title of plot", xlab="x-axis label", ylab= "y-axis label")
###grouped bar plot: (data=data, x=data$x,y=data$y, graph="bargroup",fill=data$fill, title="Title of plot", xlab="x-axis labellab", ylab="y-axis label")
###stacked bar plot: (data=data, x=data$x,y=data$y, graph="barstack",fill=data$fill, title="Title of plot", xlab="x-axis labellab", ylab="y-axis label")
###box plot: (data=data, x=data$x,y=data$y, graph="boxplot", title="Title of plot", xlab="x-axis label", ylab="y-axis label")
###box plot with correlating dots:(data=data,y=data$y, graph="dotboxplot", title="Title of plot", xlab="x-axis labellab", ylab="y-axis label")
###histogram: (data=data, x=data$x, graph="hist", title="Title of plot", xlab="x-axis label", ylab="y-axis label")
###density plot: (data=data, x=data$x, graph="densityhist", title="Title of plot", xlab="x-axis label", ylab="y-axis label")
###scatter plot: (data=data, x=data$x, y=data$y, graph="scatter",fill=data$fill, title="Title of plot", xlab="x-axis label", ylab="y-axis label", legend="Title of legend fill")
###scatter plot with correlating line: (data=data, x=data$x, y=data$y, graph="scatterline",fill=data$fill, title="Title of plot", xlab="x-axis label", ylab="y-axis label", legend="Title of legend fill")
###linear regression: (data=data, x=data$x, y=data$y, graph="linreg",fill=data$fill, title="Title of plot", xlab="x-axis label", ylab="y-axis label", legend="Title of legend fill")