R: Convert decimal degrees to dms format.

deg2dms {celestial} | R Documentation

## Convert decimal degrees to dms format.

### Description

Convert decimal degrees to dms (degrees, minutes, seconds) format. This is probably most useful for declination conversion, since dms is fairly standard method of presenting declination coordinates. The decimal degrees=d+m/60+s/3600. Degrees should range from -90 to +90.

### Usage

    deg2dms(deg, type='mat', sep=':', digits=2)

### Arguments

`deg` | The decimal degrees you are converting. All deg values should be -90<=deg<=90
`type` | The output type desired. If 'mat' then the output is a 3 column data.frame where column 1 is the degree, column 2 is the minutes and column 3 is the seconds. If 'cat' then the output is a single vector of strings where the separator is defined by the 'sep' argument.
`sep` | Defines the type of separator used when type='cat'. Any value other than 'DMS' and 'dms' is used for all separations, so the default ':' would produce an output like 3:34:45.5. If set to 'dms' or 'DMS' then the output is of the format 3d34m45.5s and 3D34M45.5s resepctively.
`digits` | The digits to print for angular seconds. See `formatC` for details on how digits is parsed.

### Value

A data.frame with the columns degrees, minutes and seconds if type='mat'. If type='cat' then a vector of strings with separators defined by the 'sep' argument.

### Author(s)

Aaron Robotham

### See Also

`dms2deg`

### Examples

    print(deg2dms(12.345))
    print(deg2dms(12.345,type='cat',sep=':'))
    print(deg2dms(12.345,type='cat',sep='dms'))
    print(deg2dms(12.345,type='cat',sep='DMS'))

[Package celestial version 1.4.1 Index]