Hello -

Have both astronomic and geodetic data sets with values in the form
"ddd:mm:ss.sssss", where dd is an integer between -180 and 180, mm is an
integer between 0 and 60, and ss is a floating-point
number between 0 and 60.0.  In order to do anything useful with these
values they need to be turned into their "decimal degree" equivalent.

Assuming the data is a vector y, the following works, sort of:

z<-strsplit(as.character(y),split=":")
zz<-sapply(z,as.numeric)
x<- t(c(1,1/60,1/3600) %*% zz)

Trouble comes if there are any NA's in the data.  In this case, R refuses
to coerce zz into matrix form, but leaves it as a "list of lists".  How can
the above routine be patched up to pass NAs through?
I can think of some inelegant solutions (e.g.  recoding NA as "-200:-1:-1")
but surely there is a better way!
Or is this the wrong technique?

More generally, is there a way to "unzip" a character vector along some
split marker, handling irregulatirites gracefully?  For example, from

y<-c("aaa#bbb", "ccc#ddd", "eee","fff"),

strsplit(y,split="#") would produce

c(c("aaa","bbb"), c("ccc","ddd"), c("eee","fff")).

Is there a way to produce instead

c(c("aaa","ccc","eee"),c("bbb","ddd","fff")) ?

Thanks for your assistance.

<>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<>
George Heine, PhD
Mathematical Analyst
National IRM Center
U.S. Bureau of Land Management
voice   (303) 236-0099
fax       (303) 236-1974
pager   (303) 826-8182 or [EMAIL PROTECTED]
<>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<>

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to