
R
u_7890
这个作者很懒,什么都没留下…
展开
-
R中读取配置文件
config.yml内容为host : foo.example.com name : Foo Base user : user453 pass : zoomR中读取的代码为library(yaml)config = yaml.load_file("config.yml")参考:https://stackoverflow.com/questions/5272846...原创 2020-02-26 19:42:21 · 581 阅读 · 0 评论 -
R语言接受命令行参数
比如希望对try.R文件用如下命令行来运行Rscript try.R -a 1 -b astring其中参数a是整数,参数b是字符串,则在try.R文件中可以用library(getopt)spec <- matrix( c("aParameter", "a", 1, "integer", "bParameter", "b", 1, "characte...原创 2019-10-06 23:05:41 · 792 阅读 · 0 评论 -
Rstudio中显示循环的进度条
Rstudio中显示循环的进度条https://blog.youkuaiyun.com/wendaomudong_l2d4/article/details/78019514转载 2019-06-15 14:05:55 · 4032 阅读 · 0 评论 -
【R】删去data.frame中指定列名的列
比如df包含['a','b','c']列,想去掉'a'列subset(df, select = -a)https://stackoverflow.com/questions/6286313/remove-an-entire-column-from-a-data-frame-in-r转载 2019-06-19 14:10:35 · 15031 阅读 · 0 评论 -
【R】填补vector中缺失值
x <- c(1,2,NA,4,5)x[is.na(x)] <- 0转载 2019-06-19 11:00:03 · 304 阅读 · 0 评论 -
linux中后台运行R代码
以try.R为例,在此代码首行增加#! /usr/bin/env Rscript然后在命令行Rscript try.R &>nohup.out&ref:https://www.cnblogs.com/hunttown/p/5802082.html原创 2019-04-03 12:57:52 · 5215 阅读 · 0 评论 -
怎么在python里调用R
1.安装[windows]conda install rpy2 2.把R的路径添加在环境变量中如果用pip install rpy2 报错了Tried to guess R's HOME but no R command in the PATH 2.具体调用可见教程一般的例子【具体见https://yulongniu.bionutshell.org/blog/2012/0...原创 2018-12-21 10:32:47 · 1791 阅读 · 2 评论 -
R中读入xlsx
install.packages("readxl")library(readxl)X_data = read_excel('file.xlsx',sheet=1,na="NA")原创 2018-10-27 14:10:35 · 324 阅读 · 0 评论 -
【整理】R中让某一列的元素随机缺失
[问答] 如何用R模拟完全随机缺失数据?library(simFrame)bar<-rnorm(100,10,1) # databar2<-as.data.frame(bar) # 形式记得转化,否则报错nc<-NAControl(NArate=0.2) #set missing ratex<-setNA(bar2,nc)...转载 2018-06-13 18:47:29 · 936 阅读 · 0 评论