随笔分类 - [31] R
摘要:You should use either indexing or the subset function. For example : R> df <- data.frame(x=1:5, y=2:6, z=3:7, u=4:8) R> df x y z u 1 1 2 3 4 2 2 3 4 5
阅读全文
摘要:按照某列的值拆分data.frameMy data is like this (for example):ID Rate State1 24 AL2 35 MN3 46 FL4 34 AL5 78 MN6 99 FLI want to split the ...
阅读全文
摘要:The font AdobePiStd is missing. Affected text will be displayed using a substitute font.缺少字体 AdobePiStd。将使用替换字体显示受影响的文本。. I solved this by copying the...
阅读全文
摘要:Merging Data Adding Columns To merge two data frames (datasets) horizontally, use the merge function. In most cases, you join two data frames by one o
阅读全文
摘要:# sorting examples using the mtcars datasetattach(mtcars)# sort by mpgnewdata <- mtcars[order(mpg),]# sort by mpg and cylnewdata <- mtcars[order(mpg,
阅读全文
摘要:R免费使用;统计工具;# 注释,行注释块注释:anything="这是注释的内容"常用R语言编辑器:Rsutdio,Tinn-R,Eclipse+StatET;中文会有乱码帮助:?,help; ?boxplot, help(boxplot),help("[[")运行R文件:source('abc.R
阅读全文
摘要:args_test.R 代码如下:Args <- commandArgs()cat("Args[1]=",Args[1],"\n")cat("Args[2]=",Args[1],"\n")cat("Args[3]=",Args[3],"\n")cat("Args[4]=",Args[4],"\n")
阅读全文
摘要:df<-NULL new_row<-data.frame(colA="xxx",colB=123) df<-rbind(df,new_row)
阅读全文
摘要:#==============================# ggplot2: subscript in x-axis labels(ticks) rm(list=ls(all=TRUE))library(ggplot2)data <- data.frame(names=tolow...
阅读全文
摘要:折线图-ggplot2 http://blog.163.com/yugao1986@126/blog/static/6922850820131161531421/http://blog.sina.com.cn/s/blog_7cffd1400101f50v.html《R Graphics Cookb...
阅读全文
摘要:在线画韦恩图(Draw venn diagram online)网站: http://jura.wi.mit.edu/bioc/tools/venn.php http://bioinformatics.psb.ugent.be/webtools/Venn/ http://bioinfogp.cnb.
阅读全文
摘要:注意:R的升级必须先卸载(在R的目录中运行 make uninstall;或运行 yum remove R )再重新安装(下载/解压/configure/make/make install) Linux (RedHat, CentOS)上升级R语言: sudo yum install R Windo
阅读全文
摘要:f <- function(start_time) { start_time <- as.POSIXct(start_time) dt <- difftime(Sys.time(), start_time, units="secs") # Since you only want the H:M...
阅读全文
摘要:Arithmetic OperatorsOperatorDescription+addition-subtraction*multiplication/division^ or ** exponentiationx %% y modulus (x mod y) 5%%2 is 1x %/% y in...
阅读全文
摘要:cat("the total number is:",3+5,"\n")print(x, ...)?print?cat?format ?write
阅读全文
摘要:sessionInfo() 查看R中载入的包和版本 writeLines(capture.output(sessionInfo()), "sessionInfo.txt") sink("sessionInfo.txt") sessionInfo() sink() data.frame 动态确定列名称
阅读全文
摘要:test for data typeis.numeric(), is.character(), is.vector(), is.matrix(), is.data.frame()convert it as.numeric(), as.character(), as.vector(), as.m...
阅读全文
摘要:Sys.Date( ) returns today's date. 显示当前日期date() returns the current date and time. 显示当前日期和时间# print today's datetoday <-Sys.Date()format(today, format=
阅读全文
摘要:字符串长度: nchar("hello world") #字符串连接:paste() #paste(..., sep = " ", collapse = NULL)#字符串分割:strsplit() #strsplit(x, split, extended = TRUE, fixed = FALSE
阅读全文
摘要:numbers <- c(4,23,4,23,5,43,54,56,657,67,67,435, 453,435,324,34,456,56,567,65,34,435)a <- table(numbers)aa[names(a)==435]as.data.frame(table(numbers))...
阅读全文