博文

目前显示的是 六月, 2020的博文

R 计算月龄

library(lubridate) calc_age <- function(birthDate, refDate = Sys.Date()) {   require(lubridate)   period <- as.period(interval(birthDate, refDate),unit = "days")   period$day } #满8月龄 ymd('2020-05-31') %m-% months(3*12) ymd('2019-12-31') %m+% months(1:12)

hosts修改

vim  /etc/hosts 0.0.0.0 account.jetbrains.com 0.0.0.0 www.jetbrains.com 127.0.0.1 transact.netsarang.com 127.0.0.1 update.netsarang.com 127.0.0.1 www.netsarang.com 127.0.0.1 www.netsarang.co.kr 127.0.0.1 sales.netsarang.com

分组建模

mtcars %>%   group_by(cyl) %>%   group_modify(     ~broom::tidy(lm(mpg ~ wt, data = .))   ) mtcars %>%   group_by(cyl) %>%   summarise(     broom::tidy(lm(mpg ~ wt))   ) mtcars %>%   group_by(cyl) %>%   summarise(     broom::tidy(lm(mpg ~ wt, data = cur_data()))   ) mtcars %>%   group_by(cyl) %>%   nest() %>%   mutate(model = purrr::map(data, ~ lm(mpg ~ wt, data = .))) %>%   mutate(result = purrr::map(model, ~ broom::tidy(.))) %>%   unnest(result) mtcars %>%   nest_by(cyl) %>%   mutate(model = list(lm(mpg ~ wt, data = data))) %>%   summarise(broom::tidy(model)) mtcars %>%   nest_by(cyl) %>%   summarise(     broom::tidy(lm(mpg ~ wt, data = data))   )