-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExampleProject.R
77 lines (44 loc) · 2.51 KB
/
ExampleProject.R
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
rm(list=ls()) # clears everything in R memory
dev.off() # clears plots from R studio
workingDirectory <-"~/Dropbox/_NDpostdoc/DataInjestion/MarkB" # Set working directory
setwd(workingDirectory)
dataFileName <-"MarkB.csv" # name of CSV output from tableau
depositorShortName <- "Ageep" # This is used to make study/sample name etc
YearToExport <-"" # Keep as "" if not doing years or it will break something else
library(dplyr)
library(maps)
library(ggplot2)
source("~/Dropbox/_NDpostdoc/DataInjestion/SamSAF_maker.R") #This pulls in all my magic scipts etc that do / check etc everything
mydata <- read.csv(dataFileName, stringsAsFactors = FALSE)
checkFieldNames(mydata)
mydata <- fixCommonFieldNameIssues(mydata)
checkFieldNames(mydata)
# Rename Mis-named Fields
# use the pattern:
# mydata <- rename(mydata,"new variable name" = "existing variable name")
# Hard Code Some Values:
# use the pattern:
# mydata$variableName <- "value" (no quotes if number)
# WARNING: This is most likely place a very bad error that won't be caught will be introduced.
# Make sure you intend on using these values, as they overright anything in the inport file
#mydata$GPS_qualifier <- "IA"
#mydata$developmental_stage <- "adult"
#mydata$sex <- "female"
#mydata$attractant <- NA
#mydata$trap_type <- "CDCLIGHT"
# Remove extraenous fields:
# use the pattern:
# mydata$variableNameToRemove <- NULL
#mydata$location_description <- trimws(mydata$location_description) #help standarize location_descriptions by trimming white space
checkFieldNames(mydata)
checkDataForCommonErrors(mydata)
#mydata <- OneYearOnly(mydata, as.numeric(YearToExport)) # If wanted, only export one year, YearToExport above.
mydata <- samplesCollectionNzeros(mydata) # Adds sample and collection IDs, removes zeros, makes blank collections
mydata <- SAF_standarize(mydata)
# Plot average point on map to make sure its in right place.
p <- plotAvgGPSpoints(mydata)
p
mydata.config <- configMaker(mydata,depositorShortName)
writeFiles(mydata, mydata.config,depositorShortName,YearToExport, writeConfig = TRUE) #Write files | if writeConfig = FALSE, config file not written (e.g. you have been manually editing it)
print(PopBioWizzardHelper(depositorShortName,YearToExport)) #Prints out line of code to paste into console to run Dan's SAF wizzard
file.copy("~/Dropbox/_NDpostdoc/DataInjestion/PopBioWizard.pl", workingDirectory) # Puts a copy of the SAF wizzard into the working directory