% select(what, height, feet) what height feet 1 Eiffel Tower 324.0 [m] 1063.0 [ft] 2 E Matua Ngahere (giant kauri tree in New Zealand) 29.9 [m] 98.1 [ft] However, this doesn't really mean anything to me. How about in bananas? how_big %>% mutate(feet = set_units(height, "ft")) %>% mutate(bananas = as_banana(height)) %>% select(what, height, feet, bananas) what height feet 1 Eiffel Tower 324.0 [m] 1063.0 [ft] 2 E Matua Ngahere (giant kauri tree in New Zealand) 29.9 [m] 98.1 [ft] bananas 1 1822 small 2 168 small Yes I made a stupid package to express things in bananas. Not one size though, it tries to match it to small or large bananas and it rounds it up to nearest banana. What about the height and length of an Alpaca? Alpaca % slice(6) %>% select(what, height, width) Alpaca what height width 1 Alpaca (shoulder height) 0.99 [m] 1.22 [m] Alpaca_banana % mutate( banana_h = as_banana(height), banana_w = as_banana(width) ) Alpaca_banana what height width banana_h banana_w 1 Alpaca (shoulder height) 0.99 [m] 1.22 [m] 4 large 7 small That is right. An alpaca is approximately 4 large bananas high up to the shoulder and 7 small bananas long. A small dive into banana properties I'm using (probably the word here is 'abusing') the vctrs package to create a new class of s3-vector. In the package I tell work out how transformations from numeric, and units and integers go to bananas and back. I made a mistake somewhere because I can multiply a number with a banana, but not a banana with a numeric. Anyways the {vctrs} package is super fun and a joy to work with! What I did was, I define a different print method for the banana vector. And so inside data.frames and the str() function, it uses this print method. bananavec"> 表达香蕉大小潜入{vctrs} |188bet appR-博客 - 188金宝搏app

决不会错过的更新!
订阅R-博客188bet app接受
最新R帖子的电子邮件。
(您将不会再看到这条消息。)

单击此处关闭(此弹出窗口将不再出现)