Convertir radianes a grado / grado a radianes
¿Hay funciones incorporadas en R para la conversión de radianes a grado y grado a radianes?
Hasta ahora he escrito mis propias funciones:
rad2deg <- function(rad) {(rad * 180) / (pi)}
deg2rad <- function(deg) {(deg * pi) / (180)}
#test:
rad2deg(pi) #180
rad2deg(2*pi) #360
deg2rad(180) #pi
25
3 answers
El comentario de Pascal fue muy útil y encontré varios, por ejemplo,
install.packages("NISTunits", dependencies = TRUE)
library(NISTunits)
NISTdegTOradian(180)
NISTradianTOdeg(pi)
10
Author: Iris,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-03 09:33:10
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-03 09:33:10
Si tiene un dato.marco Que podría ayudarle
En mi caso davis_2 w wd es la columna en grado
#Add column to Data Base
davis_2$radian_wd = davis_2$wd
#Create a loop to change the data, and change the 62'th col to Radians
for(i in 1:nrow(davis_2)){
davis_2[i, 62] = (davis_2[i, 62]*pi)/180
}
# Review
head(davis_2$radian_wd)
0
Author: Edwin Torres,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-12 01:40:38
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-12 01:40:38
Puede usar el paquete units
para esto.
library(units)
pi_rad <- as_units(pi, "radians")
pi_deg <- set_units(pi_rad, "degrees")
set_units(pi_deg, "radians")
0
Author: jsta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-10-03 18:34:09
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-10-03 18:34:09