[R] Using earth.dist function

R. Michael Weylandt michael.weylandt at gmail.com
Wed Feb 22 02:48:31 CET 2012


Your problem isn't in earth.dist but one step earlier in the call to
data(). As the warning message says, it can't find your data...most of
the time, data() is only used for built-in data sets; if you are
bringing your own data to R you need to get it in another way: this
might help http://cran.r-project.org/doc/manuals/R-data.html

Michael

On Tue, Feb 21, 2012 at 1:42 PM, cmartin <fireweed44 at shaw.ca> wrote:
> Hi Everyone,
>
> I am a graduate student who will be using R to do my analysis.  I need to do
> a spatial analysis, and the first step is to calculate the geographic
> distance between my study sites.  I am hoping to use earth.dist because it
> allows for multiple pairwise distances to be calculated at one time.  I have
> done a sample calculation, and I seem to have a problem between the steps of
> using create.lats and earth.dist.  I've copied the steps I've taken in R
> since I am NOT computer literate and have a real problem debugging computer
> programming.  Hopefully someone can help.
>
>
>> create.lats(weatherstations,loc="locality",long="longitude",lat="latitude")
>                   longitude latitude
> Adra                 -119.58    49.73
> Bankier Chain Lake   -120.28    49.70
> Chute Lake           -119.53    49.68
> Douglas Lake         -120.20    50.16
> Hedley               -120.08    49.36
> Hedley NP Mine       -120.02    49.37
>> data(weatherstations.lats)
> Warning message:
> In data(weatherstations.lats) : data set ‘weatherstations.lats’ not found
>> earth.dist(weatherstations.lats)
> Error in earth.dist(weatherstations.lats) :
>  object 'weatherstations.lats' not found
>> earth.dist(weatherstations)
>   1  2  3  4  5
> 2 NA
> 3 NA NA
> 4 NA NA NA
> 5 NA NA NA NA
> 6 NA NA NA NA NA
> There were 50 or more warnings (use warnings() to see the first 50)
>>
> Thanks! Cloe
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Using-earth-dist-function-tp4407892p4407892.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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