Skip to content

Commit 5679118

Browse files
committed
change file handling to single file handling and purge redundant code blocks
1 parent c823626 commit 5679118

4 files changed

Lines changed: 209 additions & 248 deletions

File tree

global.R

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,14 @@
66
###Visualizer Map###
77
####################
88

9-
# Loading and preparing PS data from StaMPS export
10-
# library package
11-
library(lubridate)
12-
139
# looking for study site data in stusi folder
1410
dat.path <- list.files("input/stusi/")
15-
16-
# prepare objects to read data
17-
ps.loc <- list()
18-
dates.days <- list()
19-
dates.date <- list()
20-
ref.points <- list()
21-
22-
# read data into R
23-
for(i in 1:length(dat.path)){
24-
dat <- read.csv(paste("input/stusi/", dat.path[i], sep = ""))
25-
dates.days[[i]] <- as.vector(t(dat[1, 4:ncol(dat)]))
26-
dates.date[[i]] <- as_date(dates.days[[i]], origin = "0000-01-01")
27-
ref.points[[i]] <- as.vector(t(dat[1, 1:2]))
28-
dat <- dat[c(2:nrow(dat)), ]
29-
rownames(dat) <- seq(length = nrow(dat))
30-
ps.loc[[i]] <- cbind(uid = 1:nrow(dat), lon = dat[, 1],
31-
lat = dat[, 2], disp = dat[, 3],
32-
dat[, 4:ncol(dat)])
33-
}
34-
3511
# prepare study site name
3612
str.rev <- function(x){sapply(lapply(strsplit(x, NULL), rev), paste, collapse = "")}
3713
stusi <- str.rev(dat.path)
3814
stusi <- substr(stusi, 5, 50)
3915
stusi <- str.rev(stusi)
40-
41-
# tidy up
42-
rm(dat)
43-
44-
##############################
16+
stusi <- c("---", stusi)
4517

4618
#################
4719
##Baseline Plot##
@@ -53,7 +25,6 @@ rm(dat)
5325
# looking for baseline info csv files
5426
dat.path <- list.files("input/baseline_info/", pattern = ".csv")
5527

56-
str.rev <- function(x){sapply(lapply(strsplit(x, NULL), rev), paste, collapse = "")}
5728
bl.info <- str.rev(dat.path)
5829
bl.info <- substr(bl.info, 5, 100)
5930
bl.info <- str.rev(bl.info)

0 commit comments

Comments
 (0)