[R] GPS handling libraries or (String manipulation)

Justin Haynes jtor14 at gmail.com
Wed Mar 7 17:56:38 CET 2012


Wow... that is WAY better!

Thanks Gabor!

On Wed, Mar 7, 2012 at 8:51 AM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> On Wed, Mar 7, 2012 at 11:28 AM, Alaios <alaios at yahoo.com> wrote:
>> Dear all,
>> I would like to ask you if R has a library that can work with different GPS formats
>>
>> For example
>> I have a string of this format
>>
>> N50° 47.513 E006° 03.985
>> and I would like to convert to GPS decimal format.
>>
>> that means for example converting the part N50° 47.513
>> to 50 + 47/60 + 513/3600.
>>
>> Is it possible to do that with R?
>> What is the name of such a library?
>>
>
> Use strapply to extract the digits and convert them to numeric
> followed by matrix multiplication to apply the formula:
>
> library(gsubfn)
> x <- "N50° 47.513"
>
> c(1, 1/60, 1/3600) %*% strapply(x, "\\d+", as.numeric, simplify = TRUE)
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.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