[R] Distance between lines

David Winsemius dwinsemius at comcast.net
Tue Mar 23 00:11:58 CET 2010


On Mar 22, 2010, at 6:11 PM, Janmaat, John wrote:

> Hello,
>
> I'm trying to assess the similarity of two lines that are  
> represented as points (output of differential equation solvers).  Is  
> there a function or a package that deals with things like this?

I think that "things like this" (and "lines that are represented as  
points") is still lacking specificity and suggest that you provide a  
more concrete example. It sounds as though you are referring to iso- 
contour curves. Differential equation solutions would generally have  
local gradient functions which might be used as some sort of local  
"distance" between contour "lines" which aren't really lines but  
rather curves or functions. (High gradient == short distance.) You may  
want to refit in R if you can offer local z values on an x-y grid.

?contourLines

 > x <- 10*1:nrow(volcano)
 > y <- 10*1:ncol(volcano)
 > str(contourLines(x, y, volcano))
List of 20
  $ :List of 3
   ..$ level: num 100
   ..$ x    : num [1:47] 870 860 851 850 840 ...
   ..$ y    : num [1:47] 341 341 350 351 351 ...
  $ :List of 3
   ..$ level: num 100
   ..$ x    : num [1:16] 791 800 810 820 821 ...
   ..$ y    : num [1:16] 10 19.1 19.1 19.1 20 ...
  $ :List of 3
   ..$ level: num 100
   ..$ x    : num [1:11] 870 861 860 850 841 ...
   ..$ y    : num [1:11] 111 120 121 121 130 ...
<snipped>

If you are looking for packages that might be germane in some sense to  
the topic of differential equations, I suggest CRAN Task Views:  
"Chemometrics and Computational Physics" or "Optimization and  
Mathematical Programming":

http://finzi.psych.upenn.edu/views/ChemPhys.html
http://cran.r-project.org/web/views/Optimization.html


-- 
David Winsemius, MD

>
> Thanks,
>
> John.
>
>
> ====================================================
> Johannus (John) Janmaat
> Assistant Professor of Economics
> Barber School of Arts and Sciences
> University of British Columbia - Okanagan
> john.janmaat at ubc.ca
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list