博文

目前显示的是 2018的博文

R 地图

library(readxl) library(tidyverse) library(REmap) data = data.frame(country = mapNames("world"),                   value = 5*sample(178)+200) out = remapC(data,maptype = "gansu",color = 'skyblue') plot(out) #数据 #city <- mapNames("gansu") #value <- runif(21,min = 1,max = 100) #构建数据框 #data_DF <- data.frame(city,value) data_df <- read.csv('D:\\地图\\Report.csv') #绘制填充地图 result <- remapC(data_df,                  title ="甘肃省百日咳",                  maptype = "gansu",                  color = "red",                  maxdata = 100,                  mindata = 1) library(leafletCN) shi <- regionNames("甘肃省") xian <- shi %>% map(regionNames) %>% unlist() dat=data.frame(name = xian,value = runif(87)) regionNames("兰州市") demomap("兰州市") #dat = data.frame(name = regionNames("甘肃省"),value = runif(14)) geojsonMap(data_df,"甘肃&

linux下切换python2和python3

sudo rm /usr/bin/python sudo ln -s /usr/bin/python3.6 /usr/bin/python sudo rm /usr/bin/pip sudo ln -s /usr/bin/pip3 /usr/bin/pip

oracle 连接

一、linux Sys.setenv(NLS_LANG="AMERICAN_AMERICA.ZHS16GBK") library(ROracle) drv <- dbDriver("Oracle") connect.string <- paste(   "(DESCRIPTION=",   "(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.30.12)(PORT=1521))",   "(CONNECT_DATA=(SERVICE_NAME=JZDB1)))", sep = "") con <- dbConnect(drv, username = "<>", password = "<>",                  dbname = connect.string) jzjl <- dbGetQuery(con, "select * from inoc_jzjl where rownum<1000") et <- dbGetQuery(con,"select * from grda_et where rownum<1000") dbDisconnect(con) class(et) #GBK转UTF-8 library(tidyverse) library(magrittr) et %<>%   select_if(is.character) %>%   map_df(~ iconv(.x,from="GBK",to="UTF-8")) jzjl %<>%   select_if(is.character) %>%   map_df(~ iconv(.x,from = "GBK",to="UTF-8")) 二、windows Sys.setenv(JAVA_HOME='F:\\jdk-11.0.

RSelenium 爬取 中检院生物制品批签发信息公示表

#java -jar /usr/local/bin/selenium-server-standalone-3.9.1.jar library(RSelenium) library(rvest) library(stringr) library(magrittr) library(tidyverse) remDr <- remoteDriver(   remoteServerAddr = "localhost",   port = 4444,   browserName = "firefox") #打开浏览器 remDr$open() remDr$navigate("http://www.nifdc.org.cn/CL0903/") webElems <- remDr$findElements(using = "partial link text", "中检院生物制品批签发信息公示表") links <- unlist(lapply(webElems, function(e) {e$getElementAttribute("href")})) # 下一页 nextElem <- remDr$findElement(using = "partial link text", "下一页") a.elem <- nextElem$getElementAttribute('href')[[1]] remDr$navigate(a.elem) nextWebElems <- remDr$findElements(using = "partial link text", "中检院生物制品批签发信息公示表") links <- c(links,unlist(lapply(nextWebElems, function(e) {e$getElementAttribute("href")}))) dataframe <-data.frame() for (i in 1:length(links)) {   re

R 安装 rJava

错误提示 configure: error: Java Development Kit (JDK) is missing or not registered in RMake sure R is configured with full Java support (including JDK). 解决: sudo apt install openjdk-11-jdk sudo R CMD javareconf JAVAC=/usr/lib/jvm/java-11-openjdk-amd64/bin/javac JAR=/usr/lib/jvm/java-11-openjdk-amd64/bin/jar sudo R CMD javareconf JAVAC=/usr/lib/jvm/java-11-oracle/bin/javac JAR=/usr/lib/jvm/java-11-oracle/bin/jar JAVA_HOME=/usr/lib/jvm/java-11-oracle//bin/jar

自建JetBrains激活服务器

wget -- no -check-certificate -O jetbrains.sh https://pa.ci/download/shell/jetbrains.sh && chmod +x jetbrains.sh && bash jetbrains.sh 激活程序运行后,将开启1027激活端口

R 分类汇总及类型转换

#分类汇总 litter %>% group_by(dose) %>%   summarize(mean=mean(weight)) #类型转换 litter %>% map_if(is.factor,as.character)

RSelenium安装和使用

1、安装geckodriver 下载https://github.com/mozilla/geckodriver/releases sudo cp ./geckodriver / /usr/local/bin/ sudo chmod 755 /usr/local/bin/geckodriver 2、安装 Selenium Server   下载 https://selenium-release.storage.googleapis.com/index.html sudo cp selenium-server-standalone-3.9.1.jar /usr/local/bin/ sudo chmod 755 /usr/local/bin/selenium-server-standalone-3.9.1.jar 3、运行 Selenium Server   java -jar selenium-server-standalone-3.9.1.jar 4、 library(RSelenium) rD <- rsDriver() remDr <- remoteDriver(   remoteServerAddr = "localhost",   port = 4444,   browserName = "firefox") #打开浏览器 remDr$open() # 瀏覽 Google 首頁 remDr$navigate("https://www.google.com/")

使用chmod如何给文件夹递归授予权限

find /path -type f -exec chmod 777 {} \; 修改文件权限 find /path -type d -exec chmod 777 {} \;修改文件夹权限

R 3.5 安装及更新

安装 vim /etc/apt/sources.list  deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/     sudo apt-get update   sudo apt-get install build-essential git gfortran libxml2-dev libfreetype6-dev  libbz2-dev liblapack-dev libpcre++-dev liblzma-dev libcurl4-openssl-dev libssl-dev libgdal-dev libgdal1i libudunits2-dev libjq-dev libcairo2-dev libprotobuf-dev libv8-3.14-dev  protobuf-compiler libftgl2 libcgal-dev libglu1-mesa-dev libglu1-mesa-dev libx11-dev  libfreetype6-dev libproj - dev -y   sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9   sudo apt-get install r-base r-base-dev     更新 rvcheck::update_all()       安装LaTeX install.packages ( "tinytex" ) tinytex :: install_tinytex () # install TinyTeX 安装odbc及驱动 sudo apt-get install unixodbc unixodbc-dev devtools::install_github("r-dbi/odbc") sudo wget https://drivers.rstudio.org/7C152C12/odbc-install.sh sudo chmod +x odbc-install

dttm数据类型过滤

library(nycflights13) library(tidyverse) flights_dt <- flights %>% filter(!is.na(dep_time)) glimpse(flights_dt) #dbl数据类型和chr数据类型过滤 test <- flights %>% filter(air_time==227) test <- flights %>% filter(dest=="IAH") #dttm数据类型过滤 library(lubridate) time1 <- ymd_hms('2013-01-01 05:00:00') test <- flights %>% filter(time_hour == ymd_hms('2013-01-01 05:00:00')) test <- flights %>% filter(time_hour>time1) flights$overtime <- flights$time_hour+days(1) interval(flights$time_hour,time1)

V2ray websocket(ws)+tls+nginx分流

图片
一、准备域名 这里 http://www.dot.tk/en/index.html?lang=en ,可免费申请域名。按 Use DNS 将 IP address 设定为 VPS 的 IP 地址。 二、安装 v2ray nginx 1 、安装 wget unzip daemon 等 apt install unzip daemon jq wget vim 2 、安装 v2ray bash <(curl -L -s https://install.direct/go.sh ) 记录 port 和 UUID 。 比如: PORT:28434 UUID:d38c9abd-dacc-4aee-bab5-6fd44c9fc324 3 、安装 EasyEngine ,它內置了 Nginx 和 Let’s Encrypt wget - qO ee rt .cx / ee && sudo bash ee 安装中需要输入名字和邮箱,安装完需要如下命令使用 source / etc / bash_completion .d / ee_auto .rc 使用如下命令申请 Let’s Encrypt ssl 证书 ee site create xuefliang.ga – html – letsencrypt 出现错误,使用如下命令进行查看 cat / var / log / letsencrypt / letsencrypt .log 4 、将 v2ray 加入 nginx, 需要需改红色的端口号 vim /var/www/xuefliang.ga/conf/nginx/v2ray.conf location /enterv2ray/ { proxy_redirect off; proxy_pass http://127.0.0.1: 28434; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_hea

安装RODBC

sudo apt install unixodbc unixodbc-dev install.packages("RODBC")

ubuntu 双网卡同工

sudo route add default gw 192.168.50.1 wlx7cdd90fcc5d8 sudo route add -net 10.78.0.0 netmask 255.255.0.0 gw 192.168.20.254 dev eno1 sudo route add -net 192.168.30.0 netmask 255.255.255.0 gw 192.168.20.254 dev eno1 sudo route add -net 172.16.0.0 netmask 255.255.0.0 gw 192.168.20.254 dev eno1 sudo route add -net 10.112.0.0 netmask 255.255.0.0 gw 192.168.50.1 dev wlx7cdd90fcc5d8

c++: internal compiler error: Killed (program cc1plus)

vps 内存不足 增加交换分区方式解决 dd if=/dev/zero of=/var/swap.img bs=1024k count=1000 mkswap /var/swap.img swapon /var/swap.img

数据预处理

##  5.1 数据抽样 # 5.1.2 类失衡处理方法:SMOTE # 利用Thyroid Disease 数据来研究 # 下载数据 hyper <-read.csv('http://archive.ics.uci.edu/ml/machine-learning-databases/thyroid-disease/hypothyroid.data',                  header=F) names <- read.csv('http://archive.ics.uci.edu/ml/machine-learning-databases/thyroid-disease/hypothyroid.names',                   header=F, sep='\t')[[1]] # 对对象names删除冒号和句号 names <- gsub(pattern =":|[.]", replacement="", x = names) # 对对象hyper的列进行重命名 colnames(hyper)<-names colnames(hyper) # 我们将第一列的列名从 hypothyroid, negative改成target,并将该列中的因子negative变成0,其他值变成1 colnames(hyper)[1]<-"target" colnames(hyper) hyper$target<-ifelse(hyper$target=="negative",0,1) # 检查下0、1的结果 table(hyper$target) prop.table(table(hyper$target)) # 利用SMOTE对类失衡问题进行处理 # 将变量target变成因子型 hyper$target <- as.factor(hyper$target) # 加载DMwR包 if(!require(DMwR)) install.packages("DMwR") # 进行类失衡处理 # perc.over=10

win10 自定义希腊字母

1、运行charmap.exe,找到对应的希腊字母,复制。 2、用户自定义短语 chi  粘贴

R语言特征选择

图片
ibrary(Boruta) library(mice) library(missForest) library(caret) library(randomForest) Boruta 法 boruta 算法运行的步骤: 1. 首先,它通过创建混合副本的所有特征(即阴影特征)为给定的数据集增加了随机性。 2. 然后,它训练一个随机森林分类的扩展数据集,并采用一个特征重要性措施(默认设定为平均减少精度),以评估的每个特征的重要性,越高则意味着越重要。 3. 在每次迭代中,它检查一个真实特征是否比最好的阴影特征具有更高的重要性(即该特征是否比最大的阴影特征得分更高)并且不断删除它视为非常不重要的特征。 4. 最后,当所有特征得到确认或拒绝,或算法达到随机森林运行的一个规定的限制时,算法停止。 traindata <- read.csv ( "/home/xuelfiang/PycharmProjects/titanic/titanic.csv" , header = T, stringsAsFactors = F, na.strings = T) str (traindata) ## 'data.frame': 891 obs. of 12 variables: ## $ PassengerId: int 1 2 3 4 5 6 7 8 9 10 ... ## $ Survived : int 0 1 1 1 0 0 0 0 1 1 ... ## $ Pclass : int 3 1 3 1 3 3 1 3 3 2 ... ## $ Name : chr "Braund, Mr. Owen Harris" "Cumings, Mrs. John Bradley (Florence Briggs Thayer)" "Heikkinen, Miss. Laina" "Futrelle, Mrs. Jacques Heath (Lily May Peel)" ... ## $ Sex : chr "male" &quo