SCM

SCM Repository

[nbpmatching] Diff of /pkg/R/utils.R
ViewVC logotype

Diff of /pkg/R/utils.R

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

revision 14, Mon Nov 5 17:59:50 2012 UTC revision 17, Fri May 16 20:47:17 2014 UTC
# Line 3  Line 3 
3  # list of names for created/fake elements found in matched dataset  # list of names for created/fake elements found in matched dataset
4  created.names <- c("phantom", "ghost", "chameleon")  created.names <- c("phantom", "ghost", "chameleon")
5    
6  # get a factor variable out of a nonbimatch match  #'Get named sets of matches
7    #'
8    #'Create a factor variable using the names from a matched data set.
9    #'
10    #'Calculate a name for each pair by using the ID columns from the matched data
11    #'set.  Return a factor of these named pairs.
12    #'
13    #'@aliases get.sets get.sets,data.frame-method
14    #'@param matches A data.frame object.  Contains information on how to match the
15    #'covariate data set.
16    #'@param remove.unpaired A boolean value.  The default is to remove elements
17    #'matched to phantom elements.
18    #'@param \dots Additional arguments, not used at this time.
19    #'@return a factor vector
20    #'@exportMethod get.sets
21    #'@author Cole Beck
22    #'@examples
23    #'
24    #'df <- data.frame(id=LETTERS[1:25], val1=rnorm(25), val2=rnorm(25))
25    #'df.dist <- gendistance(df, idcol=1)
26    #'df.mdm <- distancematrix(df.dist)
27    #'df.match <- nonbimatch(df.mdm)
28    #'get.sets(df.match$matches)
29    #'# include the phantom match
30    #'get.sets(df.match$matches, FALSE)
31    #'
32  setGeneric("get.sets", function(matches, remove.unpaired=TRUE, ...) standardGeneric("get.sets"))  setGeneric("get.sets", function(matches, remove.unpaired=TRUE, ...) standardGeneric("get.sets"))
33  setMethod("get.sets", "data.frame", function(matches, remove.unpaired=TRUE, ...) {  setMethod("get.sets", "data.frame", function(matches, remove.unpaired=TRUE, ...) {
34      # thanks to Jake Bowers for providing this function      # thanks to Jake Bowers for providing this function
# Line 14  Line 39 
39      factor(f.sets)      factor(f.sets)
40  })  })
41    
42  # calculate scalar distance  #'Calculate scalar distance
43    #'
44    #'Calculate the scalar distance between elements of a matrix.
45    #'
46    #'Take the absolute difference between all elements in a vector, and return a
47    #'matrix of the distances.
48    #'
49    #'@aliases scalar.dist scalar.dist,vector-method
50    #'@param x A vector of numeric values.
51    #'@param \dots Additional arguments, not used at this time.
52    #'@return a matrix object
53    #'@exportMethod scalar.dist
54    #'@author Cole Beck
55    #'@examples
56    #'
57    #'scalar.dist(1:10)
58    #'
59  setGeneric("scalar.dist", function(x, ...) standardGeneric("scalar.dist"))  setGeneric("scalar.dist", function(x, ...) standardGeneric("scalar.dist"))
60  setMethod("scalar.dist", "vector", function(x, ...) {  setMethod("scalar.dist", "vector", function(x, ...) {
61      # thanks to Jake Bowers for providing this function      # thanks to Jake Bowers for providing this function

Legend:
Removed from v.14  
changed lines
  Added in v.17

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge