library(Mreport)
library(stringr)
load_base()
load_sample_base()
allstation <- read.csv("D:\\交大云同步\\实习\\00_交调系统\\交调系统数据\\交调站点管理\\交调站数据.csv",stringsAsFactors=F)
dim(allstation)
district <- allstation$行政区划
head(district,50)
pattern <- "([^省]*省)|([^自治区]*(自治区))|(北京市)|(上海市)|(重庆市)|(天津市)"
x <- str_extract(district,pattern)
unique(x)
allstation$省份 <- x
pattern <- "((?<=省)[^(自治州|直辖县)]*?市)|(北京市)|(上海市)|(重庆市)|(天津市)|(?<=自治州).*(市|县)|((?<=省直辖县级行政区划).*?市)"
x <- str_extract(district,pattern)
unique(x)
allstation$<- x
sum(is.na(allstation$市))
head(allstation[is.na(allstation$市),])
str_detect("辽宁省锦州市市辖区","((?<=省)[^自治州]*?市)")


ahorawzy/Mreport documentation built on May 3, 2019, 3:40 p.m.