博文

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

ifelse sqlite

library(DBI) library(openxlsx) library(tidyverse) library(magrittr) library(hablar) con <- dbConnect(RSQLite::SQLite(), "~/Downloads/phone.db") dbListTables(con) phones <- dbGetQuery(con, "select * from phones") #phones <- tbl(con,sql("select * from phones")) %>% collect() regions <- dbGetQuery(con, "select * from regions") phones %<>%   left_join(regions,by=c('region_id'='id')) %>%   select(number,province,city,zip_code,area_code) dbDisconnect(con) df2015 <- read.xlsx('./Downloads/甘肃全国12320数据至-20200223.xlsx',sheet = 1) %>%   mutate(year=2015) df2016 <- read.xlsx('./Downloads/甘肃全国12320数据至-20200223.xlsx',sheet = 2) %>%   mutate(year=2016) df2017 <- read.xlsx('./Downloads/甘肃全国12320数据至-20200223.xlsx',sheet = 3) %>%   mutate(year=2017) df2018 <- read.xlsx('./Downloads/甘肃全国12320数据至-20200223.xlsx',sheet = 4) %>%   mutate(year=2018) df

hablar 类型转换

library(hablar) mtcars %>%   convert(num(gear),           chr(mpg),           fct(cyl)) df <- data.frame(a = c("A", NA, "B", "C", "C"),                  b = c(NA, 1, 1, 3, 3),                  c = c(7, 8, 2, 3, 3),                  stringsAsFactors = FALSE) # Returns duplicated rows df %>% find_duplicates() df %>% find_duplicates(b:c) df %>% find_na(b)