博文

R 返回包含“社区卫生服务中心”数量

图片
men <- read.csv("/home/xuefliang/Downloads/men.csv",header = F) b <- grep("社区卫生服务中心",men$V1) length(b) a <- grepl("社区卫生服务中心",men$V1) #grep仅返回匹配项的下标,而grepl返回所有的查询结果,并用逻辑向量表示有没有找到匹配。windows csv文件ANSI编码需用记事本修改为UTF-8

linux mint语言选项 丢失

sudo apt-get install mintlocale

R on vps tips Setting LC_COLLATE failed, using "C"

sudo apt-get install language-pack-en-base sudo dpkg-reconfigure locales    错误提示 “ Unable to connect to service ”  adduser xuefliang #非root用户组   vi /etc/rstudio/rserver.conf www-port = 8787 rsession-which-r=/usr/bin/R 用rstudio-server verify-installation进行验证     locale::facet::_S_create_c_locale name not valid解决方案    export LC_ALL="C"  

R计算排列和组合

图片
library(combinat) permn(3) length(permn(3)) combn(1000, 2) dim(combn(1000,2))[2] 组合(Combinations)和排列( Permutation )计算公式为 perm = function(n, x) {   return(factorial(n) / factorial(n-x)) } comb = function(n, x) {   return(factorial(n) / (factorial(x) * factorial(n-x))) } 组合数:choose(n, k) 注意:从n个中选出k个 阶乘(k!):factorial(k) 排列数:choose(n, k) * factorial(k)

R 语言求极限

library(rSymPy) sympy("limit(1/x, x, oo)") sympy("limit(1/x, x, 0)") sympy("limit(x*log(x), x, 0)")  sympy("limit(sin(x)/x*x, x, 0)") sympy("limit(exp(x)/x*x, x, 0)") sympy("limit(x**x, x, 0)") sympy("limit(x*exp(1)**-x, x, oo)")  ##**代表幂 sympy("limit((cos(x)-1)/x**2, x, 0)")

ubuntu下安装goldendict及离线词库

1.sudo apt-get install goldendict 2.播放语音 sudo apt-get install mplayer sudo apt-get install ubuntu-restricted-addons sudo apt-get install ubuntu-restricted-extras 3.批量解压离线词库 #! /bin/bash # run this script to install goldendict and off-line dictionaries # Only for Ubuntu # created by longbin <beangr@163.com> # 2014-03-28 function goldendict_essential_install(){     for file in ${FILE_LIST}     do         trap 'echo -e "\nInterrupted by user"; exit' INT         echo -e "\n======================================="         echo -e "Preparing to install ${file} ..."         echo -e "======================================="         echo -e "\tsudo apt-get install ${file}"         sudo apt-get install ${file}     done     RET...

R 3.1 -> 3.2 upgrade notes

1.cp -r ~/R/x86_64-pc-linux-gnu-library/3.1/* ~/R/x86_64-pc-linux-gnu-library/3.2 # at the shell prompt 2.update.packages(checkBuilt=TRUE, ask=FALSE) #at the R prompt