gpt4 book ai didi

r - 如何将度数(列)转换为弧度

转载 作者:行者123 更新时间:2023-12-05 08:36:52 24 4
gpt4 key购买 nike

这是示例的样子:

# A tibble: 10 x 6
trip_id bearing_1 bearing_2 bearing_3 bearing_4 bearing_5
<int> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 -115. 26.0 28.5 29.0 44.2
2 2 -30.0 -104. -151. -79.7 86.3
3 3 -174. -163. 28.9 28.4 33.4
4 4 109. 39.7 108. -90.4 -96.4
5 5 164. 173. 172. -155. -151.
6 6 29.7 28.8 23.7 23.7 -5.72
7 7 -152. -152. -140. -87.8 -40.4
8 27393 36.8 -7.35 125. 125. -6.25
9 27394 38.2 8.01 8.01 8.01 8.01
10 27395 -66.6 -68.0 112. 86.0 -2.03
 my.df <- structure(list(trip_id = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 27393L,27394L, 27395L), bearing_1 = c(-114.841862569466, -29.9669766757283,-174.421109701553, 108.540950375186, 164.27892942256, 29.6758222025729,-151.952759961779, 36.7666184516413, 38.1774435895225, -66.5951081074832), bearing_2 = c(26.0208400403598, -103.956520193288, -162.685454728109,39.7241781616749, 172.795046874931, 28.7700915265229, -151.570082970024,-7.34765841903149, 8.00631142918635, -68.0088533670534), bearing_3 = c(28.5429778503258,-150.523766272678, 28.9060358290049, 107.799736478861, 171.649870654995,23.6732326703023, -139.805993936888, 124.715023127817, 8.00631142918635,111.724971807071), bearing_4 = c(29.0047950732172, -79.7472910710283,28.4442392651495, -90.3662617366973, -155.498976426312, 23.6732326703023,-87.7511498573422, 124.715023127817, 8.00631142918635, 85.9719398622447), bearing_5 = c(44.1517444467334, 86.2565875990879, 33.44598675342,-96.4423762052258, -150.883228746413, -5.72113572073526, -40.42741337969,-6.24787371298153, 8.00631142918635, -2.0336505253902)), row.names = c(NA,-10L), class = c("tbl_df", "tbl", "data.frame"))

因此,bearing_1bearing_5 列是度数,我想将此 degree value 转换为 radians value . R 中是否有任何包和函数可以计算这个?

我的预期结果应该是这样的,

# A tibble: 10 x 6
trip_id radian_1 radian_2 radian_3 radian_4 radian_5
<int> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 -2.007128 0.4537855 0.4974188 0.5061454 0.7714354
2 2 -0.5235987 -1.815142 -2.635447 -1.391027 1.506219

最佳答案

my.df[,2:6] <- my.df[,2:6] * pi / 180

关于r - 如何将度数(列)转换为弧度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67388300/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com