博文

目前显示的是 五月, 2019的博文

Install Oracle Java 13 in Ubuntu

sudo add-apt-repository ppa:linuxuprising/java sudo apt-get update sudo apt-get install oracle-java13-installer oracle-java13-set-default java -version #查询jdk的安装路径 #前提条件是设置 echo $JAVA_HOME #查java命令位置 which java #查软链: ls -l /usr/bin/java #查jdk目录 ls -l /etc/alternatives/java #配置JAVA_HOME export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac)))) #将上述命令中的一条写入 ~/.bashrc(或 /etc/profile)文件中

gganimate动画

library(gganimate) library(gapminder) library(tidyverse) #sudo apt install cargo #install.packages("gifski") data("gapminder") glimpse(gapminder) gapminder %>%   select(country, pop, year, continent) %>%   group_by(year) %>% # for each year we assign a rank   arrange(year, -pop) %>%   mutate(rank = 1:n()) %>% # assign ranking   filter(rank <= 10) ->   ranked_by_year my_theme <- theme_classic(base_family = "Times") +   theme(axis.text.y = element_blank()) +   theme(axis.ticks.y = element_blank()) +   theme(axis.line.y = element_blank()) +   theme(legend.background = element_rect(fill = "linen")) +   theme(plot.background = element_rect(fill = "linen")) +   theme(panel.background = element_rect(fill = "linen")) ggplot(data = ranked_by_year) +   aes(group = country, fill = continent) +   aes(xmin = 0 ,       xmax = pop / 1000000) +   aes(ymin = rank - .45,       ymax = rank + .45) +   scale_y_reverse() +  

时序数据异常检测

library(tidyverse) library(anomalize) data("tidyverse_cran_downloads") # time_decompose():将时间序列分为季节性,趋势和余数 # anomalize():将异常检测方法应用于余数组件。 # time_recompose():计算将“正常”数据与异常分开 tidyverse_cran_downloads %>%   ggplot(aes(date, count)) +   geom_point(color = "#2c3e50", alpha = 0.25) +   facet_wrap(~ package, scale = "free_y", ncol = 3) +   theme_minimal() +   theme(axis.text.x = element_text(angle = 30, hjust = 1)) +   labs(title = "Tidyverse Package Daily Download Counts",        subtitle = "Data from CRAN by way of cranlogs package") tidyverse_cran_downloads %>%   # Data Manipulation / Anomaly Detection   time_decompose(count, method = "stl") %>%   anomalize(remainder, method = "iqr") %>%   time_recompose() %>%   # Anomaly Visualization   plot_anomalies(time_recomposed = TRUE, ncol = 3, alpha_dots = 0.25) +   labs(title = "Tidyverse Anomalies", subtitle = "STL + IQR Methods") # Get only lu

anytime 时间类型转换

times <- c("2004-03-21 12:45:33.123456","2004/03/21 12:45:33.123456","20040321 124533.123456","03/21/2004 12:45:33.123456","03-21-2004 12:45:33.123456","2004-03-21","20040321","03/21/2004","03-21-2004","20010101") tmp <- anytime(times) anydate(times) utctime(times) utcdate(times)

时序数据处理tibbletime

#时序数据处理 library(tibbletime) library(tidyverse) # filter_time()函数:简洁的切片操作 # collapse_index()函数:根据时间(例如年、月、每两周等)对索引列进行分割,进而利用dplyr包的分组函数计算汇总数据 # as_period()函数:改变一个time tibble的时间间隔,让日数据变为周数据/月数据更为简单 # rolliyf()函数:滚动分析 # create_series()函数:快捷地创建tbl_time类型的时序数据 # 索引列完美支持Date和POSIXct类型,初步支持yearmon,yearqtr和hms类型。 data("FB") #将常规的数据框转化为tbl_time FB_tbl_time <- FB %>%   as_tbl_time(index = date) # 提取2013年3月至2015年的数据,这里`~`两边的时间/日期都包含在内 FB_tbl_time %>%   filter_time(time_formula = '2013-03'~'2015') # 提取2013年1月2日至2013年12月31日的数据 FB_tbl_time %>%   filter_time(time_formula = "2013-01-02" ~ "2013-12-31") # dplyr操作 # FB_tbl_time %>% #   filter(date >= as.Date("2013-01-02"), date <= as.Date("2013-12-31")) # 提取2013年一整年的数据 FB_tbl_time %>%   filter_time(time_formula = "2013" ~ "2013") FB_tbl_time %>%   filter_time(time_formula = ~ "2013") # 提取从序列开始到2015年的所有数据,包含2015年 FB_tbl_time %>%  

数据探索

--- title: "Untitled" author: "xuefliang" date: "6/16/2019" output: html_document editor_options: chunk_output_type: console --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library(inspectdf) library(tidyverse) library(readr) data(starwars) #install_github("alastairrushworth/inspectdf") ``` ```{r} df= read_csv('https://raw.githubusercontent.com/lgellis/STEM/master/DATA-ART-1/Data/FinalData.csv', col_names = TRUE) allGrades <- df oldGrades <- allGrades %>% filter(Grade > 5) youngGrades <- allGrades %>% filter(Grade < 6) ggplot(oldGrades, aes(x=Grade)) + geom_histogram() ggplot(youngGrades, aes(x=Grade)) + geom_histogram() ``` ## inspect_types() 检查变量类型 ```{r} inspect_types(allGrades)%>% show_plot() inspect_types(youngGrades, oldGrades) %>% show_plot() ``` ## inspect_mem() 大小信息,包括数据框列、行、总大小和每个变量的大小。 ```{r} inspect_mem(allGrades)%>% show_plot() inspect_mem(youngGrades, ol

爬虫 生物制品批签发产品情况汇总

#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://bio.nifdc.org.cn/pqf/search.do?formAction=pqfGsByJG&orgId=1") webElems <- remDr$findElements(using = "partial link text", "生物制品批签发产品情况汇总") links <- unlist(lapply(webElems, function(e) {e$getElementAttribute("href")})) dataframe <-data.frame() for (i in 1:length(links)) {     remDr$navigate(links[i])     Sys.sleep(1)     childWebElem <- remDr$findElement(using='xpath',"/html/body/center/div/div[2]/table/tbody/tr/td/table/tbody/tr")   childWebElem <- remDr$findElement(using='xpath',"/html/body/center/div/div[2]/table/tbody/tr/td/table/tbody&qu

socks 全局

1 sudo apt install polipo sudo vim /etc/polipo/config   socksParentProxy="localhost:1080"   socksProxyType=socks5 2  sudo service polipo stop  sudo service polipo start 3  Network proxy>Manual  Http Proxy 127.0.0.1:8123  Https Proxy 127.0.0.1:8123  FTP Proxy 127.0.0.1:8123

数据探索 summarytools包

#sudo apt install libmagick++-dev library(summarytools) data("tobacco") dfSummary(tobacco) print(dfSummary(tobacco),method = 'render') descr(tobacco$BMI) descr(tobacco$BMI,weights = tobacco$samp.wgts) freq(tobacco$disease) freq(tobacco$disease,weights = tobacco$samp.wgts) ctable(tobacco$disease,tobacco$gender)

ROracle on Linux

1. sudo apt-get install alien sudo apt-get install libaio1 2. Download:   oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm oracle-instantclient12.1-devel-12.2.0.1.0-1.x86_64.rpm oracle-instantclient12.1-sqlplus-12.2.0.1.0-1.x86_64.rpm (http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html) 3. sudo alien -i oracle-instantclient12.1-basic-12.2.0.1.0-1.x86_64.rpm sudo alien -i oracle-instantclient12.1-devel-12.2.0.1.0-1.x86_64.rpm sudo alien -i oracle-instantclient12.1-sqlplus-12.2.0.1.0-1.x86_64.rpm 4. export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} export ORACLE_HOME=/usr/lib/oracle/12.2/client64 export PATH=$PATH:$ORACLE_HOME/bin echo "/usr/lib/oracle/12.2/client64/lib" | sudo tee /etc/ld.so.conf.d/oracle.conf sudo ldconfig -v 5. echo $LD_LIBRARY_PATH echo $ORACLE_HOME echo $PATH sqlplus   # should give you the command prompt sudo chmod 755  /usr/local/lib/R/site-li

echarter入门

devtools::install_github("cardiomoon/moonBook") devtools::install_github("cardiomoon/webr") require(ggplot2) require(moonBook) require(webr) devtools::install_github("jeevanyue/echarter") library(echarter) library(tidyverse) dataStyle <- list(   normal = list(     label = list(show = FALSE),     labelLine = list(show = FALSE)   ) ) placeHolderStyle <- list(   normal = list(     color ='rgba(0, 0, 0, 0)',     label = list(show = FALSE),     labelLine = list(show = FALSE)   ),   emphasis = list(     color = 'rgba(255,0,0,0)'   ) ) #修改主题 echart(theme = 'shine')%>%   ec_title(     text = '你幸福吗?',     x = 'center',     y = 'center',     itemGap = 20,     textStyle = list(       color = 'rgba(30,144,255,0.8)',       fontFamily = '微软雅黑',       fontSize = 15,       fontWeight = 'bolder'     )   ) %>%   ec_tooltip(     show = TRUE, trigger = &#

R donut plot

library(tidyverse) df<- data.frame(variable=rep(c("亲朋好友", "医生", "媒体网络", "医学书籍", "其它")),                  value=c(3137,2276,2056,84,7)) df$prop <- round(df$value/sum(df$value),2) df$variable <- factor(df$variable, levels = df$variable[order(df$prop)]) p <- ggplot(df, aes(x = "", y = value, fill = variable)) +   geom_bar(width = 1, stat="identity") +   coord_polar("y", start=pi / 3) + ggtitle("Pie Chart") p <- ggplot(df, aes(x = variable, y = prop, fill = variable)) +   geom_bar(stat="identity")+   coord_polar("y")+   theme_bw() print(p) p <- ggplot(df, aes(x = variable, y = value, fill = variable)) +   geom_bar(width = 0.9, stat="identity") +   coord_polar("y")+   theme_bw() print(p) p <- ggplot(df, aes(x = variable, y = value, fill = variable)) +   geom_bar(width = 1, stat="identity") +     coord_polar(theta = "x",dir

redsocks 全局转发

1、配置redsocks sudo apt install redsocks base {     // debug: connection progress     log_debug = off;     // info: start and end of client session     log_info = on;     /* possible `log' values are:      *   stderr      *   "file:/path/to/file"      *   syslog:FACILITY  facility is any of "daemon", "local0"..."local7"      */     log = stderr;     // log = "file:/path/to/file";     // log = "syslog:local7";     // detach from console     daemon = on;     /* Change uid, gid and root directory, these options require root      * privilegies on startup.      * Note, your chroot may requre /etc/localtime if you write log to syslog.      * Log is opened before chroot & uid changing.      * Debian, Ubuntu and some other distributions use `nogroup` instead of      * `nobody`, so change it according to your system if you want redsocks      * to drop root privileges.      */     // user = nobody;     // group = nobody;     // ch