Skip to content

Commit d1c5eca

Browse files
author
Jordan S Read
committed
Merge pull request #293 from jread-usgs/master
changes per @jiwalker-usgs comments from last PR
2 parents a27a00e + cc42bf5 commit d1c5eca

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: gsplot
22
Type: Package
33
Title: Geological Survey Plotting
4-
Version: 0.5.0
5-
Date: 2015-12-05
4+
Version: 0.5.1
5+
Date: 2015-12-13
66
Authors@R: c( person("Jordan", "Read", role = "aut",
77
email = "[email protected]"),
88
person("Laura", "DeCicco", role = c("aut","cre"),

R/access-gsplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ logged.gsplot <- function(object, side=NULL){
8282
#' @return data frame with one row per view. Each view has an x side, y side, the log command, and the view index.
8383
#' @export
8484
view_info <- function(object){
85-
j <- grep('view.', names(object))
85+
j <- which_views(object)
8686
viewSides <- sapply(j, function(x) object[[x]][['window']][['side']])
8787
viewLogs <- sapply(j, function(x) object[[x]][['window']][['log']])
8888
viewInfo <- data.frame(t(rbind(viewSides, viewLogs, j)), stringsAsFactors = FALSE)

R/calc_views.R

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ calc_views <- function(gsplot){
2424
return(views)
2525
}
2626

27+
which_views <- function(gsplot){
28+
grep('view.', names(gsplot))
29+
}
30+
2731
views <- function(gsplot){
28-
gsplot[grep('view.', names(gsplot))]
32+
gsplot[which_views(gsplot)]
2933
}
3034

3135
non_views <- function(gsplot){
3236
non.views <- gsplot
33-
non.views[grep('view.', names(non.views))] <- NULL
37+
non.views[which_views(non.views)] <- NULL
3438
return(non.views)
3539
}
3640

@@ -92,7 +96,7 @@ which_reals <- function(values, na.value){
9296

9397
}
9498
set_view_window <- function(views, param, na.value=NA, remove=TRUE, ignore=NULL){
95-
view_i <- grep('view.', names(views))
99+
view_i <- which_views(views)
96100
for (i in view_i){
97101
values <- lapply(views[[i]][!names(views[[i]]) %in% ignore], function(x) strip_pts(x, param))
98102
val.i <- which_reals(values, na.value)
@@ -198,15 +202,15 @@ views_with_side <- function(views, side){
198202
if(length(side) > 1)
199203
stop('side can only be length of 1')
200204
with.side = lapply(views, function(x) any(x[['window']][['side']] %in% side))
201-
view.match = unname(unlist(with.side[grep('view.', names(views))]))
205+
view.match = unname(unlist(with.side[which_views(views)]))
202206
if (is.null(view.match) || !any(view.match))
203207
return(NULL)
204208
else
205209
return(which(view.match))
206210
}
207211

208212
get_view_side <- function(views, view_i, param){
209-
i = grep('view.', names(views))[view_i]
213+
i = which_views(views)[view_i]
210214
sides <- views[[i]][['window']][['side']]
211215
if (param=='y')
212216
return(sides[which(sides %% 2 == 0)])
@@ -218,7 +222,7 @@ get_view_side <- function(views, view_i, param){
218222

219223
summarize_args <- function(views, param, na.value, ignore='gs.config'){
220224

221-
view_i <- grep('view.', names(views))
225+
view_i <- which_views(views)
222226
values <- list()
223227
for (i in view_i){
224228
x <- views[[i]][!names(views[[i]]) %in% ignore]
@@ -260,7 +264,7 @@ set_window <- function(list){
260264
listOut <- list
261265
pars <- list[['par']]
262266

263-
for(j in grep('view.', names(list))){
267+
for(j in which_views(list)){
264268

265269
window <- list[[j]][['window']]
266270
plots <- list[[j]]

0 commit comments

Comments
 (0)