Hello Jim,

Thanks. It works. Great. 

By the way, I am beginner in R. 

All the best,

Mehdi



--- On Wed, 10/6/10, jim holtman <jholtman@gmail.com> wrote:

From: jim holtman <jholtman@gmail.com>
Subject: Re: [R] Help to trafnsform data!
To: "Mehdi Zarrei" <gagzarrei@yahoo.com>
Cc: r-help@r-project.org
Date: Wednesday, October 6, 2010, 2:37 PM

try this:

> input <- read.table(textConnection("31;39;00N+65;40;00E T
+ 36;31;42N+69;04;21E T
+ 34;10;00N+69;41;00E T
+ 34;34;00N+69;06;00E T
+ 31;40;00N+65;44;00E T
+ 35;00;00N+69;07;00E T
+ 34;00;00N+69;53;00E T"), sep = "+", as.is = TRUE)
> closeAllConnections()
> result <- NULL
> for (i in 1:2){
+     # remove trailing letters
+     x.s <- sub("^([^[:alpha:]]*).*", '\\1', input[[i]])
+     x.split <- strsplit(x.s, ";")
+     x.s1 <- sapply(x.split, function(.coord){
+         .coord <- as.numeric(.coord)
+         .coord[1L] + .coord[2L] / 60 + .coord[3L] / 3600
+     })
+     result <- cbind(result, x.s1)
+ }
> result
         x.s1     x.s1
[1,] 31.65000 65.66667
[2,] 36.52833 69.07250
[3,] 34.16667 69.68333
[4,] 34.56667 69.10000
[5,] 31.66667 65.73333
[6,] 35.00000 69.11667
[7,] 34.00000 69.88333
>


On Wed, Oct 6, 2010 at 1:51 PM, Mehdi Zarrei <gagzarrei@yahoo.com> wrote:
> Dear R users,
>
> I have huge dataset like the bellow (prepared in notepad in txt format:
>
> 31;39;00N+65;40;00E T
> 36;31;42N+69;04;21E T
> 34;10;00N+69;41;00E T
> 34;34;00N+69;06;00E T
> 31;40;00N+65;44;00E T
> 35;00;00N+69;07;00E T
> 34;00;00N+69;53;00E T
>
> These are geographical coordinates, degree minute, seconds.
>   latitude      longitude
> 31;39;00N+65;40;00E T
>
> I would like to plot them on the map. I would like to know to how separate longitude and longitude from each other and put them into two different columns and then transform the degree minute second into decimal format.
>
> Your help very appreciated.
>
> Mehdi
>
>
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@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.
>
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



      
	[[alternative HTML version deleted]]

