-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGreyFishScript_ExploratoryPlots.R
More file actions
134 lines (80 loc) · 3.82 KB
/
GreyFishScript_ExploratoryPlots.R
File metadata and controls
134 lines (80 loc) · 3.82 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#<pre>
########################################################
# GREYFISH TOOLKIT - EXPLORATORY ANALYSIS AND PLOTS #
# developed by Gottfried Pestal of SOLV Consulting Ltd.#
########################################################
# THIS SCRIPT CREATES 1 PAGE OF DIAGNOSTIC PLOTS, FIRST FOR ALL RECORDS, THEN FOR EACH COUNTRY, THEN FOR EACH REPORT SERIES
# THIS SCRIPT REQUIRES THE FILE "GreyFish_CustomFunctions.r" AND A DATA FILE IN THE SAME DIRECTORY
#######################
# Version Tracker #
# v 2 - July 2013 #
#######################
# read in custom functions for analysis and plotting
source("GreyFish_CustomFunctions.R")
file.name <- "MergedFile.csv"
###############################################
# EDA AND DIAGNOSTIC PLOTS FOR ALL REPORT TYPES
# calculate simple diagnostics (see comments in "GreyFish_CustomFunctions.r" for details)
eda.out <- greyfish_eda(file=file.name,reports="all")
# open pdf file for output
pdf("GreyFish_ExploratoryPlots_AllRecords.pdf",width=11,height=8.5,onefile=TRUE)
# create plots (see comments in "GreyFish_CustomFunctions.r" for details)
greyfish_edaplots1(eda.out, main.label=paste("All GreyFish Records",Sys.Date()))
# close pdf output
dev.off()
###############################################
# EDA AND DIAGNOSTIC PLOTS FOR EACH COUNTRY
# Get a list of countries
data.file<-read.csv(file.name)
country.list <- sort(unique(data.file[,"Country"]))
# open pdf file for output
pdf("GreyFish_ExploratoryPlots_ByCountry.pdf",width=11,height=8.5,onefile=TRUE)
# loop through countries
for(country in country.list){
print(country)
reports.list <- unique(paste(data.file[data.file[,"Country"]==country,"Agency"],data.file[data.file[,"Country"]==country,"ReportSeries"],sep="-"))
print(reports.list)
# calculate simple diagnostics (see comments in "GreyFish_CustomFunctions.r" for details)
eda.out <- greyfish_eda(file="MergedFile.csv",reports=reports.list,print.data=FALSE)
# create a page of plots (see comments in "GreyFish_CustomFunctions.r" for details)
greyfish_edaplots1(eda.out, main.label=paste(country,Sys.Date()))
} # end looping through report types
# close pdf output
dev.off()
###############################################
# EDA AND DIAGNOSTIC PLOTS FOR EACH AGENCY
# Get a list of agencies
data.file<-read.csv(file.name)
agency.list <- sort(unique(data.file[,"Agency"]))
# open pdf file for output
pdf("GreyFish_ExploratoryPlots_ByAgency.pdf",width=11,height=8.5,onefile=TRUE)
# loop through agencies
for(agency in agency.list){
print(agency)
reports.list <- unique(paste(data.file[data.file[,"Agency"]==agency,"Agency"],data.file[data.file[,"Agency"]==agency,"ReportSeries"],sep="-"))
print(reports.list)
# calculate simple diagnostics (see comments in "GreyFish_CustomFunctions.r" for details)
eda.out <- greyfish_eda(file="MergedFile.csv",reports=reports.list,print.data=FALSE)
# create a page of plots (see comments in "GreyFish_CustomFunctions.r" for details)
greyfish_edaplots1(eda.out, main.label=paste(agency,Sys.Date()))
} # end looping through agencies
# close pdf output
dev.off()
###############################################
# EDA AND DIAGNOSTIC PLOTS FOR EACH REPORT TYPE
# Get a list of report types
data.file<-read.csv(file.name)
report.list <- unique(paste(data.file[,"Agency"],data.file[,"ReportSeries"],sep="-"))
# open pdf file for output
pdf("GreyFish_ExploratoryPlots_ByReportType.pdf",width=11,height=8.5,onefile=TRUE)
# loop through report types
for(i in report.list){
print(i)
# calculate simple diagnostics (see comments in "GreyFish_CustomFunctions.r" for details)
eda.out <- greyfish_eda(file="MergedFile.csv",reports=i,print.data=FALSE)
# create a page of plots (see comments in "GreyFish_CustomFunctions.r" for details)
greyfish_edaplots1(eda.out, main.label=paste(i,Sys.Date()))
} # end looping through report types
# close pdf output
dev.off()
#</pre>