SCM

SCM Repository

[maptools] Diff of /pkg/R/colslegs.R
ViewVC logotype

Diff of /pkg/R/colslegs.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 162, Wed Nov 17 15:40:01 2010 UTC revision 297, Wed Jun 10 13:55:43 2015 UTC
# Line 1  Line 1 
1  # Copyright 2000-2001 (c) Nicholas Lewin-Koh  # Copyright 2000-2001 (c) Nicholas Lewin-Koh
2  # modifications 2001-2003 (c) Roger Bivand  # modifications 2001-2003 (c) Roger Bivand
3    # modifications 201506 Nick Bearman
4    
5    
6  # Returns a vector of HSV values  # Returns a vector of HSV values
# Line 40  Line 41 
41    return(NULL)    return(NULL)
42  }  }
43    
44  leglabs <- function(vec, under="under", over="over", between="-") {  #updated leglabs function to allow order of entries to be reversed
45    
46    leglabs <- function(vec, under="under", over="over", between="-", reverse = FALSE) {
47          x <- vec          x <- vec
48          lx <- length(x)          lx <- length(x)
49          if(lx < 3) stop("vector too short")          if(lx < 3) stop("vector too short")
50      if(reverse) { #if user asks order to be reversed
51        #reorder variable
52    #    x<-reverseorder(x)
53        x<-rev(x)
54        #set new under and over values
55        under <- "over"
56        over <- "under"
57      }
58          res <- character(lx-1)          res <- character(lx-1)
59          res[1] <- paste(under, x[2])          res[1] <- paste(under, x[2])
60          for (i in 2:(lx-2)) res[i] <- paste(x[i], between, x[i+1])          for (i in 2:(lx-2)) res[i] <- paste(x[i], between, x[i+1])
# Line 51  Line 62 
62          res          res
63  }  }
64    
65    #reverseorder <- function(old.var){
66      #function to reverseorder any set of values, designed for use with legends in maptools library
67      #copy variable to be reordered
68    #  new.var <- old.var
69      #loop going through each value in turn
70    #  for (i in 1:length(old.var)) {
71        #save it in the appropiate place in the new variable
72    #    new.var[length(old.var)+1-i] <- old.var[i]
73    #  }
74      #return new variable
75    #  return(new.var)
76    #}
77    
78    #x
79    
80    #x
81  #The set of classification methods is large (Dent p. 145), but there are a few to remember:  #The set of classification methods is large (Dent p. 145), but there are a few to remember:
82    
83  #        * Equal Intervals ("Constant Interval"): each class has same difference in value  #        * Equal Intervals ("Constant Interval"): each class has same difference in value

Legend:
Removed from v.162  
changed lines
  Added in v.297

R-Forge@R-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge