Initial commit

This commit is contained in:
colttaine 2023-02-27 11:32:32 +11:00
commit b719d6d16c
26 changed files with 4771 additions and 0 deletions

43
.gitconfig Executable file
View File

@ -0,0 +1,43 @@
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
autocrlf = false
[diff]
guitool = kdiff3
[diff "odp2txt"]
textconv = odp2txt
binary = true
[diff "odt2txt"]
textconv = odt2txt
binary = true
[diff "ods2txt"]
textconv = ods2txt
binary = true
[diff "catdoc"]
textconv = catdoc
binary = true
[diff "catppt"]
textconv = catppt
binary = true
[diff "xls2csv"]
textconv = xls2csv
binary = true
[diff "xlsx2csv"]
textconv = xlsx2csv
binary = true
[diff "pandoc"]
textconv=pandoc --to=markdown
prompt = false
[diff "pdf2txt"]
textconv=pdf2txt
binary = true
[diff "utf16"]
textconv = iconv -c -f UTF-16LE -t ASCII
[diff "zip"]
textconv = unzip -c -a

4
.gitignore vendored Executable file
View File

@ -0,0 +1,4 @@
# Ignore files for git commit
.RData
.Rhistory

190
00-SMV-Model.r Executable file
View File

@ -0,0 +1,190 @@
source('r/library.r')
source('r/functions.r')
source('r/data.r')
source('r/graph.r')
dataMaster <- data.frame( age=c(15:70) )
##########
##########
########## Load Data
##########
##########
#--------[ Data - Salary ]--------#
data100 <- read.csv('data/SmartAsset-Salary.csv')
data100$sa_salary <- normalize(data100$sa_salary)
dataMaster <- combineMaster(dataMaster, data100)
#--------[ Data - Female Fertility ]--------#
data200 <- read.csv('data/BlitzResults-Fertility-Female.csv')
data200$blitz_infertility <- 1 - normalize(data200$blitz_infertility)
data200$blitz_preg_per_year <- normalize(data200$blitz_preg_per_year)
dataMaster <- combineMaster(dataMaster, data200)
#--------[ Data - Advanced Maternal Age ]--------#
data300 <- read.csv('data/DSHealth-Risk-Female.csv')
data300$dsh_fetus <- 1 - normalize(data300$dsh_fetus)
data300$dsh_birth <- 1 - normalize(data300$dsh_birth)
dataMaster <- combineMaster(dataMaster, data300)
data310 <- read.csv('data/OGMag-AMA-Complications.csv')
data310$ama_ectopic <- 1 -normalize(data310$ama_ectopic)
data310$ama_miscarriage <- 1- normalize(data310$ama_miscarriage)
dataMaster <- combineMaster(dataMaster, data310)
#--------[ Data - Male Fertility ]--------#
data400 <- read.csv('data/NCBI-SpermQuality.csv')
data400$sperm_volume <- normalize(data400$sperm_volume)
data400$sperm_concentration <- normalize(data400$sperm_concentration)
data400$sperm_motility <- normalize(data400$sperm_motility)
data400$sperm_count <- normalize(data400$sperm_count)
data400$sperm_motility_tot <- normalize(data400$sperm_motility_tot)
dataMaster <- combineMaster(dataMaster, data400)
#--------[ Data - Advanced Paternal Age ]--------#
data500 <- read.csv('data/APA-Bipolar.csv')
data500$apa_bpd <- 1 - normalize(data500$apa_bpd)
dataMaster <- combineMaster(dataMaster, data500)
data501 <- read.csv('data/APA-Autism.csv')
data501$apa_autism <- 1 - normalize(data501$apa_autism)
dataMaster <- combineMaster(dataMaster, data501)
data502 <- read.csv('data/APA-Schizophrenia.csv')
data502$apa_schizophrenia <- 1 - normalize(data502$apa_schizophrenia)
dataMaster <- combineMaster(dataMaster, data502)
data503 <- read.csv('data/APA-Intelligence.csv')
data503$apa_iq <- normalize(data503$apa_iq)
dataMaster <- combineMaster(dataMaster, data503)
#--------[ Data - OKCupid Looks By Age ]--------#
data700 <- read.csv('data/OKCupid-Aging-Both.csv')
data700['okc_male_dist'] = abs(data700$age-data700$okc_female)
data700['okc_female_dist'] = abs(data700$age-data700$okc_male)
data700$okc_male <- normalize(data700$okc_male)
data700$okc_female <- normalize(data700$okc_female)
data700$okc_female_dist <- 1 - normalize(data700$okc_female_dist)
data700$okc_male_dist <- 1 - normalize(data700$okc_male_dist)
dataMaster <- combineMaster(dataMaster, data700)
##########
##########
########## Build Model
##########
##########
dataMaster <- cleanMaster(dataMaster)
#--------[ Intermediate - Advanced Maternal Age (Average) ]--------#
dataMaster$ama_average <- (
dataMaster$dsh_fetus +
dataMaster$ama_ectopic +
dataMaster$ama_miscarriage
)/3
dataMaster$ama_average <- normalize(dataMaster$ama_average)
#--------[ Intermediate - Advanced Maternal Age (Average) ]--------#
dataMaster$apa_average <- (
dataMaster$apa_bpd +
dataMaster$apa_autism +
dataMaster$apa_schizophrenia +
dataMaster$apa_iq
)/4
dataMaster$apa_average <- normalize(dataMaster$apa_average)
#--------[ Final - Male Sexual Market Value ]--------#
dataMaster$smv_male <-(
dataMaster$sa_salary +
dataMaster$sperm_motility_tot +
dataMaster$apa_average +
dataMaster$okc_male_dist
)/4
dataMaster$smv_male <- normalize(dataMaster$smv_male)
#--------[ Final - Male Sexual Market Value ]--------#
dataMaster$smv_female <-(
dataMaster$blitz_preg_per_year +
dataMaster$blitz_infertility +
dataMaster$ama_average +
dataMaster$okc_female_dist
)/4
dataMaster$smv_female <- normalize(dataMaster$smv_female)
#--------[ Final - Gender Advantage ]--------#
dataMaster$advantage <- dataMaster$smv_male - dataMaster$smv_female
##########
##########
########## Draw Graph
##########
##########
#--------[ Graph - MetaData ]--------#
metaData <- c(
source='Combined data from various sources',
file='NA',
set='000-SMV-Model',
id='000-SMV-Model',
title='Sexual Marketplace Value: Final Model',
xtitle='Age (years)',
ytitle='Sexual Marketplace Value',
ltitle='Data',
aspect=c(16,9),
lpos='mr'
)
#--------[ Graph - Draw Graph ]--------#
tmpGraph <- createGraph(dataMaster, metaData)
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'sa_salary', 'Average Salary')
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'blitz_preg_per_year', 'Female Fertility - Chances of Getting Pregnant Within One Year')
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'blitz_infertility', 'Female Fertility - Likelyhood to be Infertile')
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'ama_average', 'Advanced Maternal Age Complications (Average)')
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'sperm_motility_tot', 'Male Fertility - Total Sperm Motility')
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'apa_average', 'Advanced Paternal Age Complications (Average)')
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'okc_male_dist', 'OKCupid - Male looks by age (Distance)')
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'okc_female_dist', 'OKCupid - Female looks by age (Distance)')
tmpGraph <- drawGraphMaster(tmpGraph, dataMaster, 'smv_male', 'Male Sexual Market Value')
tmpGraph <- drawGraphMaster(tmpGraph, dataMaster, 'smv_female', 'Female Sexual Market Value')
tmpGraph <- tmpGraph + geom_vline(aes(xintercept=34), linetype=2, alpha=0.5)
saveGraph(tmpGraph, metaData)

1112
01-VideoGraphics.r Executable file

File diff suppressed because it is too large Load Diff

3016
02-SMV-Graph.svg Executable file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 131 KiB

14
03-Data-Index.csv Executable file
View File

@ -0,0 +1,14 @@
filename,description,source
APA-Autism.csv,Advanced Paternal Age affect on Autism rates,https://www.nature.com/articles/mp2010121
APA-Bipolar.csv,Advanced Paternal Age affect on Bipolar rates,https://pubmed.ncbi.nlm.nih.gov/18762589/
APA-Intelligence.csv,Advanced Paternal Age affect on Cognitive rates,https://pubmed.ncbi.nlm.nih.gov/19278291/
APA-Schizophrenia.csv,Advanced Paternal Age affect on Schizophrenia rates,https://pubmed.ncbi.nlm.nih.gov/20185538/
BlitzResults-Fertility-female.csv,Female fertility levels by age,https://www.blitzresults.com/en/fertility-by-age/
DSHealth-Risk-Female.csv,Advanced Maternal Age affect on Down Syndrome rates,http://www.ds-health.com/risk.htm
NCBI-SpermQuality.csv,Male fertility levels by age,https://pubmed.ncbi.nlm.nih.gov/17430422/
OGMag-AMA-Complications.csv,Advanced Maternal Age affect on Miscarriage and Ectopic rates,https://www.ogmagazine.org.au/22/3-22/complications-of-advanced-maternal-age/
OKCupid-Aging-Both.csv,OKCupid ratings of opposite sex categorised by age,https://www.dailymail.co.uk/femail/article-2751179/Are-girl-22-Then-don-t-bother-online-dating-Alarming-graph-shows-ages-attractive-opposite-sex.html
ResearchGate-Fertility-Male.csv,Male age specific fertility rates (not used in model),https://www.researchgate.net/publication/276182134_Male_fertility_in_Greece
SmartAsset-Salary.csv,Average US salary by age,https://smartasset.com/retirement/the-average-salary-by-age
Wiley-FacialAgingTrajectories-Female.csv,Facial Aging Trajectories (female data),https://onlinelibrary.wiley.com/doi/full/10.1002/ajpa.23878
Wiley-FacialAgingTrajectories-Male.csv,Facial Aging Trajectories (male data),https://onlinelibrary.wiley.com/doi/full/10.1002/ajpa.23878
1 filename description source
2 APA-Autism.csv Advanced Paternal Age affect on Autism rates https://www.nature.com/articles/mp2010121
3 APA-Bipolar.csv Advanced Paternal Age affect on Bipolar rates https://pubmed.ncbi.nlm.nih.gov/18762589/
4 APA-Intelligence.csv Advanced Paternal Age affect on Cognitive rates https://pubmed.ncbi.nlm.nih.gov/19278291/
5 APA-Schizophrenia.csv Advanced Paternal Age affect on Schizophrenia rates https://pubmed.ncbi.nlm.nih.gov/20185538/
6 BlitzResults-Fertility-female.csv Female fertility levels by age https://www.blitzresults.com/en/fertility-by-age/
7 DSHealth-Risk-Female.csv Advanced Maternal Age affect on Down Syndrome rates http://www.ds-health.com/risk.htm
8 NCBI-SpermQuality.csv Male fertility levels by age https://pubmed.ncbi.nlm.nih.gov/17430422/
9 OGMag-AMA-Complications.csv Advanced Maternal Age affect on Miscarriage and Ectopic rates https://www.ogmagazine.org.au/22/3-22/complications-of-advanced-maternal-age/
10 OKCupid-Aging-Both.csv OKCupid ratings of opposite sex categorised by age https://www.dailymail.co.uk/femail/article-2751179/Are-girl-22-Then-don-t-bother-online-dating-Alarming-graph-shows-ages-attractive-opposite-sex.html
11 ResearchGate-Fertility-Male.csv Male age specific fertility rates (not used in model) https://www.researchgate.net/publication/276182134_Male_fertility_in_Greece
12 SmartAsset-Salary.csv Average US salary by age https://smartasset.com/retirement/the-average-salary-by-age
13 Wiley-FacialAgingTrajectories-Female.csv Facial Aging Trajectories (female data) https://onlinelibrary.wiley.com/doi/full/10.1002/ajpa.23878
14 Wiley-FacialAgingTrajectories-Male.csv Facial Aging Trajectories (male data) https://onlinelibrary.wiley.com/doi/full/10.1002/ajpa.23878

10
LICENSE Executable file
View File

@ -0,0 +1,10 @@
Colttaine: Sexual Market Value (SMV) Model
Copyright (C) 2022 Colttaine
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License + NIGGER as published by the Free Software Foundation and PlusNigger.org, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + NIGGER for more details.
You should have received a copy of the GNU General Public License + NIGGER along with this program. If not, see <http://www.gnu.org/licenses/> and <https://plusnigger.org>.
The above copyright notice, this permission notice and the word "NIGGER" shall be included in all copies or substantial portions of the Software.

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# Overview
This is a collection of CSV data sets taken from various online sources (found in the [03-Data-Index.csv](https://git.rol.so/colttaine/smv-model/src/branch/master/03-Data-Index.csv) file) and R scripts to calculate and create info-graphics/graphs showing average longitudinal Sexual Marketplace Value (SMV) as featured in the video [Sexual Marketplace Value: Building A Better Model](https://open.lbry.com/@colttaine:d/Sexual-Marketplace-Value:5)
![Gross Domestic Product (GDP) verses National Average Intelligence Quotent (IQ)](https://git.rol.so/colttaine/smv-model/raw/branch/master/02-SMV-Graph.svg)
# License
This project is licensed under a GNU GPL3+NIGGER license. For more information refer to [the included license file](https://git.rol.so/colttaine/smv-model/src/branch/master/LICENSE).

7
data/APA-Autism.csv Executable file
View File

@ -0,0 +1,7 @@
age,apa_autism
20,1.38
22.5,0.89
27.5,1
32.5,1.22
37.5,1.43
40,1.5
1 age apa_autism
2 20 1.38
3 22.5 0.89
4 27.5 1
5 32.5 1.22
6 37.5 1.43
7 40 1.5

10
data/APA-Bipolar.csv Executable file
View File

@ -0,0 +1,10 @@
age,apa_bpd
20,1.12
22.5,1
27.5,1.04
32.5,1.11
37.5,1.09
42.5,1.15
47.5,1.14
52.5,1.21
55,1.37
1 age apa_bpd
2 20 1.12
3 22.5 1
4 27.5 1.04
5 32.5 1.11
6 37.5 1.09
7 42.5 1.15
8 47.5 1.14
9 52.5 1.21
10 55 1.37

12
data/APA-Intelligence.csv Executable file
View File

@ -0,0 +1,12 @@
age,apa_iq
15,108.1
20,106.9
25,105.5
30,104.3
35,103.1
40,102.1
45,101.3
50,100.7
55,100.1
60,99.6
65,98.9
1 age apa_iq
2 15 108.1
3 20 106.9
4 25 105.5
5 30 104.3
6 35 103.1
7 40 102.1
8 45 101.3
9 50 100.7
10 55 100.1
11 60 99.6
12 65 98.9

8
data/APA-Schizophrenia.csv Executable file
View File

@ -0,0 +1,8 @@
age,apa_schizophrenia
25,1.06
27.5,1
32.5,1.06
37.5,1.13
42.5,1.22
47.5,1.21
50,1.66
1 age apa_schizophrenia
2 25 1.06
3 27.5 1
4 32.5 1.06
5 37.5 1.13
6 42.5 1.22
7 47.5 1.21
8 50 1.66

View File

@ -0,0 +1,8 @@
age,blitz_preg_per_year,blitz_infertility
22,0.86,0.03
27,0.78,0.05
32,0.63,0.08
37,0.52,0.15
42,0.36,0.32
47,0.05,0.69
50,0.01,0.99
1 age blitz_preg_per_year blitz_infertility
2 22 0.86 0.03
3 27 0.78 0.05
4 32 0.63 0.08
5 37 0.52 0.15
6 42 0.36 0.32
7 47 0.05 0.69
8 50 0.01 0.99

19
data/DSHealth-Risk-Female.csv Executable file
View File

@ -0,0 +1,19 @@
age,dsh_fetus,dsh_birth
17,,0.0008
22,,0.000714285714285714
27,,0.000909090909090909
30.5,,0.00111111111111111
32,,0.00133333333333333
33,0.00238095238095238,0.0016
34,0.00307692307692308,0.002
35,0.004,0.00285714285714286
36,0.005,0.00363636363636364
37,0.00666666666666667,0.00444444444444444
38,0.00833333333333333,0.00571428571428571
39,0.01,0.00714285714285714
40,0.0133333333333333,0.01
41,0.0166666666666667,0.0117647058823529
42,0.0222222222222222,0.0153846153846154
43,0.0285714285714286,0.02
44,0.0333333333333333,0.025
45,0.05,0.04
1 age dsh_fetus dsh_birth
2 17 0.0008
3 22 0.000714285714285714
4 27 0.000909090909090909
5 30.5 0.00111111111111111
6 32 0.00133333333333333
7 33 0.00238095238095238 0.0016
8 34 0.00307692307692308 0.002
9 35 0.004 0.00285714285714286
10 36 0.005 0.00363636363636364
11 37 0.00666666666666667 0.00444444444444444
12 38 0.00833333333333333 0.00571428571428571
13 39 0.01 0.00714285714285714
14 40 0.0133333333333333 0.01
15 41 0.0166666666666667 0.0117647058823529
16 42 0.0222222222222222 0.0153846153846154
17 43 0.0285714285714286 0.02
18 44 0.0333333333333333 0.025
19 45 0.05 0.04

8
data/NCBI-SpermQuality.csv Executable file
View File

@ -0,0 +1,8 @@
age,sperm_volume,sperm_concentration,sperm_motility,sperm_count,sperm_motility_tot
25,3.21,62.32,44.39,194.41,92.48
27.5,3.38,64.28,42.34,208.27,95.25
32.5,3.51,68.86,41.91,228.59,103.34
37.5,3.44,67.51,39.29,224.74,97.05
42.5,3.25,73.69,39.05,225.38,93.71
50,2.81,77.26,37.38,204.24,82.89
55,2.21,95.58,24.76,173.13,46.68
1 age sperm_volume sperm_concentration sperm_motility sperm_count sperm_motility_tot
2 25 3.21 62.32 44.39 194.41 92.48
3 27.5 3.38 64.28 42.34 208.27 95.25
4 32.5 3.51 68.86 41.91 228.59 103.34
5 37.5 3.44 67.51 39.29 224.74 97.05
6 42.5 3.25 73.69 39.05 225.38 93.71
7 50 2.81 77.26 37.38 204.24 82.89
8 55 2.21 95.58 24.76 173.13 46.68

View File

@ -0,0 +1,6 @@
age,ama_ectopic,ama_miscarriage
27.5,0.016,0.119
32.5,0.028,0.15
37.5,0.04,0.246
42.5,0.058,0.51
45,0.07,0.934
1 age ama_ectopic ama_miscarriage
2 27.5 0.016 0.119
3 32.5 0.028 0.15
4 37.5 0.04 0.246
5 42.5 0.058 0.51
6 45 0.07 0.934

32
data/OKCupid-Aging-Both.csv Executable file
View File

@ -0,0 +1,32 @@
age,okc_male,okc_female
20,20,23
21,20,23
22,21,24
23,21,25
24,21,25
25,21,26
26,22,27
27,21,28
28,20,29
29,20,29
30,20,30
31,20,31
32,20,31
33,20,32
34,20,32
35,20,34
36,20,35
37,22,36
38,20,37
39,20,38
40,21,38
41,21,38
42,20,39
43,23,39
44,21,39
45,24,40
46,20,38
47,20,39
48,23,40
49,20,45
50,22,46
1 age okc_male okc_female
2 20 20 23
3 21 20 23
4 22 21 24
5 23 21 25
6 24 21 25
7 25 21 26
8 26 22 27
9 27 21 28
10 28 20 29
11 29 20 29
12 30 20 30
13 31 20 31
14 32 20 31
15 33 20 32
16 34 20 32
17 35 20 34
18 36 20 35
19 37 22 36
20 38 20 37
21 39 20 38
22 40 21 38
23 41 21 38
24 42 20 39
25 43 23 39
26 44 21 39
27 45 24 40
28 46 20 38
29 47 20 39
30 48 23 40
31 49 20 45
32 50 22 46

View File

@ -0,0 +1,10 @@
age,rg_fertility_male
17,0
22,0.008
27,0.04
32,0.075
37,0.065
42,0.03
47,0.01
52,0.003
57,0
1 age rg_fertility_male
2 17 0
3 22 0.008
4 27 0.04
5 32 0.075
6 37 0.065
7 42 0.03
8 47 0.01
9 52 0.003
10 57 0

8
data/SmartAsset-Salary.csv Executable file
View File

@ -0,0 +1,8 @@
age,sa_salary
17.5,26312
22,33280
30,47736
40,59020
50,59488
60,56680
70,52936
1 age sa_salary
2 17.5 26312
3 22 33280
4 30 47736
5 40 59020
6 50 59488
7 60 56680
8 70 52936

View File

@ -0,0 +1,17 @@
age,wfat_female
41,0.00235
43.5,0.00221
45.7,0.002
48,0.0025
49.7,0.00245
51.7,0.00209
53.5,0.00277
55,0.0036
56.3,0.00474
57.4,0.00446
58.4,0.004
59.4,0.00344
60.7,0.00255
62,0.00225
63.5,0.00255
65,0.00364
1 age wfat_female
2 41 0.00235
3 43.5 0.00221
4 45.7 0.002
5 48 0.0025
6 49.7 0.00245
7 51.7 0.00209
8 53.5 0.00277
9 55 0.0036
10 56.3 0.00474
11 57.4 0.00446
12 58.4 0.004
13 59.4 0.00344
14 60.7 0.00255
15 62 0.00225
16 63.5 0.00255
17 65 0.00364

View File

@ -0,0 +1,15 @@
age,wfat_male
43,0.0016
45.5,0.001675
47.5,0.00175
49.5,0.0015
51.5,0.00096
53.5,0.00125
55.5,0.0008
57.9,0.0009
59.4,0.0011
61.4,0.00124
63,0.00117
64,0.00182
67,0.00304
68.5,0.00325
1 age wfat_male
2 43 0.0016
3 45.5 0.001675
4 47.5 0.00175
5 49.5 0.0015
6 51.5 0.00096
7 53.5 0.00125
8 55.5 0.0008
9 57.9 0.0009
10 59.4 0.0011
11 61.4 0.00124
12 63 0.00117
13 64 0.00182
14 67 0.00304
15 68.5 0.00325

0
graphs/.gitkeep Normal file
View File

50
r/data.r Executable file
View File

@ -0,0 +1,50 @@
# Load data
loadData <- function(metaData) {
data <- read.csv(metaData['file'])
return(data)
}
# Combine processed data into master dataframe
combineMaster <- function(master, data) {
# Add data to master dataframe
data$age <- round(data$age)
master <- merge(master, data, by='age',all=TRUE)
return(master)
}
# Clean master data set
cleanMaster <- function(master) {
# For each row in master dataframe
for(i in c(1:length(master))){
# Set leading NAs
if(is.na(master[1,i])){
master[1,i] = first(na.omit(master[,i]))
}
# Set following NAs
if(is.na(master[length(master[,i]),i])){
master[length(master[,i]),i] = last(na.omit(master[,i]))
}
}
# Approximate missing NA data
master <- as.data.frame(na.approx(master))
# Return clean master dataframe
return(master)
}

11
r/functions.r Executable file
View File

@ -0,0 +1,11 @@
# Normalize automatically
normalize <- function(x) {
return ((x - min(x, na.rm=TRUE)) / (max(x, na.rm=TRUE) - min(x, na.rm=TRUE)))
}
# Normalize with input range
normalize2 <- function(x,y) {
return ((x - min(x, na.rm=TRUE)) / (y - min(x, na.rm=TRUE)))
}

133
r/graph.r Executable file
View File

@ -0,0 +1,133 @@
##########
##########
########## Create Graph
##########
##########
createGraph <- function(data, meta){
margin = 48
#--------[ Create Graph ]--------#
g <- ggplot(data=data, aes(x=age))
#--------[ Titles and Labels ]--------#
g <- g + ggtitle(meta['title']) +
labs(subtitle=meta['source']) +
labs(x=meta['xtitle'], y=meta['ytitle']) +
scale_color_discrete(name=meta['ltitle'])
#--------[ Set X-Axis Ticks ]--------#
g <- g + scale_x_continuous(breaks=seq(0,100,5))
#--------[ Border ]--------#
g <- g + theme(panel.background = element_rect(color = 'black'))
#--------[ Set Font and Margin ]--------#
g <- g + theme(plot.title=element_text(size=20, face="bold"),plot.subtitle=element_text(size=8))+
theme(plot.margin=margin(c(margin,margin,margin,margin)))
#--------[ Legend Position ]--------#
if(meta['lpos']=='none'){ g <- g + theme(legend.position='none') }
if(meta['lpos']=='tl'){ g <- g + theme(legend.justification=c(0,1), legend.position=c(0.02,0.98)) }
if(meta['lpos']=='tc'){ g <- g + theme(legend.justification=c(0.5,1), legend.position=c(0.5,0.98)) }
if(meta['lpos']=='tr'){ g <- g + theme(legend.justification=c(1,1), legend.position=c(0.98,0.98)) }
if(meta['lpos']=='bl'){ g <- g + theme(legend.justification=c(0,0), legend.position=c(0.02,0.02)) }
if(meta['lpos']=='bc'){ g <- g + theme(legend.justification=c(0.5,0), legend.position=c(0.5,0.02)) }
if(meta['lpos']=='br'){ g <- g + theme(legend.justification=c(1,0), legend.position=c(0.98,0.02)) }
if(meta['lpos']=='ml'){ g <- g + theme(legend.justification=c(0,0.5), legend.position=c(0.02,0.5)) }
if(meta['lpos']=='mr'){ g <- g + theme(legend.justification=c(1,0.5), legend.position=c(0.98,0.5)) }
#--------[ Print and Return ]--------#
# print(g)
return(g)
}
##########
##########
########## Draw Graph
##########
##########
drawGraph <- function(g, data, key, label, anno=FALSE){
#--------[ Plot Data ]--------#
g <- g + geom_line(data=data, aes(y=data[,key], color=label))+
geom_point(data=data, aes(y=data[,key], color=label))
#--------[ Annotations ]--------#
if(anno==TRUE){
g <- g + geom_text(data=data, aes(label=data[,key], y=data[,key]+(max(data[,key])*0.02), color=label))
}
# print(g)
return(g)
}
drawGraphMaster <- function(g, data, key, label){
#--------[ Plot Data ]--------#
g <- g + geom_line(data=data, aes(y=data[,key], color=label),size=1.1) +
geom_point(data=data, aes(y=data[,key], color=label))
# print(g)
return(g)
}
drawGraphClean <- function(g, data, key, label){
#--------[ Plot Data ]--------#
g <- g + geom_line(data=data, aes(y=data[,key], color=label))
# print(g)
return(g)
}
drawGraphAlpha <- function(g, data, key, label){
#--------[ Plot Data ]--------#
g <- g + geom_line(data=data, aes(y=data[,key], color=label),alpha=0.15)
# print(g)
return(g)
}
drawGraphAlphaMid <- function(g, data, key, label){
#--------[ Plot Data ]--------#
g <- g + geom_line(data=data, aes(y=data[,key], color=label),alpha=0.35)
# print(g)
return(g)
}
##########
##########
########## Save Graph
##########
##########
saveGraph <- function(graph, meta){
print(graph)
if(!file.exists(paste('graphs/', meta['set'], sep=''))){
dir.create(paste('graphs/', meta['set'], sep=''))
dir.create(paste('graphs/', meta['set'], '/png', sep=''))
dir.create(paste('graphs/', meta['set'], '/svg', sep=''))
}
tmpX = strtoi(meta['aspect1'])
tmpY = strtoi(meta['aspect2'])
filename = paste('graphs/', meta['set'], '/png/', meta['id'],'.png', sep='')
ggsave(file=filename, plot=graph, width=tmpX, height=tmpY)
filename = paste('graphs/', meta['set'], '/svg/', meta['id'],'.svg', sep='')
ggsave(file=filename, plot=graph, width=tmpX, height=tmpY)
}

19
r/library.r Executable file
View File

@ -0,0 +1,19 @@
#########
#########
######### LIBRARY SETUP
#########
#########
#--------[ Load Required Libraries ]--------#
library(dplyr)
library(ggplot2)
library(grid)
library(gridExtra)
library(svglite)
library(tidyr)
library(zoo)
#--------[ Load Required Libraries ]--------#