Broken link highlighted original list of station is no longer available. Now relying on the official list on the SEPA website.
Showing 1 of 11 files from the diff.
Other files ignored by Codecov
vignettes/kilphedir.png
was deleted.
man/SEPAcatalogue.Rd
has changed.
vignettes/sepa.png
was deleted.
data/SEPAcatalogue.rda
has changed.
tests/testthat/test-catalogueSEPA.R
has changed.
R/hddtools-package.R
has changed.
vignettes/hddtools_vignette.Rmd
has changed.
vignettes/figure/SEPA2-1.png
has changed.
.Rbuildignore
has changed.
vignettes/figure/SEPA3-1.png
has changed.
@@ -30,9 +30,12 @@
Loading
30 | 30 | catalogueSEPA <- function(columnName = NULL, columnValue = NULL, |
|
31 | 31 | useCachedData = TRUE){ |
|
32 | 32 | ||
33 | - | if (useCachedData == TRUE){ |
|
33 | + | theurl <- paste0("http://apps.sepa.org.uk/database/riverlevels/", |
|
34 | + | "SEPA_River_Levels_Web.csv") |
|
34 | 35 | ||
35 | - | # message("Using cached data.") |
|
36 | + | if (RCurl::url.exists(theurl) == FALSE | useCachedData == TRUE){ |
|
37 | + | ||
38 | + | message("Using cached data.") |
|
36 | 39 | ||
37 | 40 | load(system.file(file.path("data", "SEPAcatalogue.rda"), |
|
38 | 41 | package = "hddtools")) |
@@ -41,34 +44,10 @@
Loading
41 | 44 | ||
42 | 45 | }else{ |
|
43 | 46 | ||
44 | - | theurl <- "http://pennine.ddns.me.uk/riverlevels/ConciseList.html" |
|
45 | - | ||
46 | - | if (RCurl::url.exists(theurl) == FALSE){ |
|
47 | - | ||
48 | - | # message("Using cached data.") |
|
49 | - | ||
50 | - | load(system.file(file.path("data", "SEPAcatalogue.rda"), |
|
51 | - | package = "hddtools")) |
|
52 | - | ||
53 | - | catTMP <- SEPAcatalogue |
|
54 | - | ||
55 | - | }else{ |
|
56 | - | ||
57 | - | message("Retrieving data from data provider.") |
|
47 | + | message("Retrieving data from data provider.") |
|
58 | 48 | ||
59 | - | tables <- XML::readHTMLTable(theurl) |
|
60 | - | n.rows <- unlist(lapply(tables, function(t) dim(t)[1])) |
|
61 | - | catTMP <- tables[[which.max(n.rows)]] |
|
62 | - | catTMP <- catTMP[catTMP$stationId!=0,c(1:3,5:9)] |
|
63 | - | row.names(catTMP) <- NULL |
|
64 | - | names(catTMP) <- c("idNRFA", "aspxpage", "stationId", "River", |
|
65 | - | "Location", |
|
66 | - | "GridRef", "Operator", "CatchmentAreaKm2") |
|
67 | - | ||
68 | - | catTMP[] <- lapply(catTMP, as.character) |
|
69 | - | catTMP$CatchmentAreaKm2 <- as.numeric(catTMP$CatchmentAreaKm2) |
|
70 | - | ||
71 | - | } |
|
49 | + | catTMP <- read.csv(theurl, stringsAsFactors = FALSE) |
|
50 | + | catTMP$WEB_MESSAGE <- as.character(catTMP$WEB_MESSAGE) |
|
72 | 51 | ||
73 | 52 | } |
|
74 | 53 |
@@ -76,16 +55,15 @@
Loading
76 | 55 | ||
77 | 56 | if (tolower(columnName) %in% tolower(names(catTMP))){ |
|
78 | 57 | ||
79 | - | col2select <- which(tolower(names(catTMP)) == |
|
80 | - | tolower(columnName)) |
|
58 | + | col2select <- which(tolower(names(catTMP)) == tolower(columnName)) |
|
81 | 59 | ||
82 | - | if (class(catTMP[,col2select]) == "character"){ |
|
83 | - | rows2select <- which(tolower(catTMP[,col2select]) == |
|
60 | + | if (class(catTMP[, col2select]) == "character"){ |
|
61 | + | rows2select <- which(tolower(catTMP[, col2select]) == |
|
84 | 62 | tolower(columnValue)) |
|
85 | 63 | } |
|
86 | - | if (class(catTMP[,col2select]) == "numeric"){ |
|
64 | + | if (class(catTMP[,col2select]) == "numeric" | |
|
65 | + | class(catTMP[, col2select]) == "integer"){ |
|
87 | 66 | ||
88 | - | # rows2select <- which(catTMP[,col2select] == columnValue) |
|
89 | 67 | rows2select <- eval(parse(text = |
|
90 | 68 | paste0("which(catTMP[,col2select] ", |
|
91 | 69 | columnValue, ")"))) |
@@ -160,9 +138,9 @@
Loading
160 | 138 | ||
161 | 139 | if (plotOption == TRUE){ |
|
162 | 140 | ||
163 | - | locationSEPA <- catalogueSEPA(columnName = "stationID", |
|
164 | - | columnValue = id) |
|
165 | - | plot(myTS, main = locationSEPA$Location, |
|
141 | + | locationSEPA <- catalogueSEPA(columnName = "LOCATION_CODE", |
|
142 | + | columnValue = paste("==", id)) |
|
143 | + | plot(myTS, main = locationSEPA$STATION_NAME, |
|
166 | 144 | xlab = "", ylab = "River level [m]") |
|
167 | 145 | ||
168 | 146 | } |
Files | Coverage |
---|---|
R | 35.45% |
Project Totals (7 files) | 35.45% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.