随笔分类 - [31] R
摘要:A data frame is used for storing data tables. It is a list of vectors of equal length. For example, the following variable df is a data frame containi
阅读全文
摘要:library(splines) library(ggplot2) dt1 <- structure(list(Age = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
阅读全文
摘要:报错: In read.table("abc.txt", header = T) : incomplete final line found by readTableHeader on 'abc.txt' 解决方法: 在数据文件abc.txt最后一行加上回车即可解决。
阅读全文
摘要:R语言拆分字符串 aaa<-"aa;bb;cc"ccc<-strsplit(aaa,split=";") bbb<- unlist(strsplit(aaa,split=";")) ; bbbbbb[2]str(bbb)length(bbb)
阅读全文
摘要:?unlist Given a list structure x, unlist simplifies it to produce a vector which contains all the atomic components which occur in x.unlist(v.row)[1]
阅读全文
摘要:Generate a random number between 5.0 and 7.5x1 <- runif(1, 5.0, 7.5) # 参数1表示产生一个随机数x2 <- runif(10, 5.0, 7.5)# 参数10表示产生10个随机数Generate a random integer
阅读全文
摘要:############################################ INSTALLMENT############################################ try http:// if https:// URLs are not supportedsou
阅读全文
摘要:替换空值: foo <- data.frame("day"= c(1, 3, 5, 7), "od" = c(0.1, "#N/A", 0.4, 0.8)) NAs <- foo == "#N/A" ## by replace method is.na(foo)[NAs] <- TRUE ## or
阅读全文
摘要:The figure 1a does not draw any lines, while the figure 1b works well.The key concept is “group” in aes.The rule is simple: So, by specifying group=g
阅读全文
摘要:x<-data.frame(apple=c(1,4,2,3),pear=c(4,8,5,2)) x # apple pear # 1 1 4 # 2 4 8 # 3 2 5 # 4 3 2 x$banana<-c(9,5,6,2) x # apple pear banana # 1 1 4 9 # 2 ...
阅读全文
摘要:ggplot2中的legend包括四个部分: legend.tittle, legend.text, legend.key, legend.backgroud。针对每一部分有四种处理方式:element_text()绘制标签和标题,可控制字体的family, face, colour, size,
阅读全文
摘要:library(ggplot2) REF: http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_%28ggplot2%29/ http://www.rdocumentation.org/packages/bear/functi
阅读全文
摘要:Graphical ParametersYou can customize many features of your graphs (fonts, colors, axes, titles) through graphic options.One way is to specify these o...
阅读全文
摘要:1 Windows: 键入 cd C:\Program Files\R\R-3.2.0\bin 工作目录切换到R的核心程序目录 键入 R BATCH F:\Test.R 或 Rscript F:\Test.R 运行脚本 前者R控制台内容记录到Test.Rout文件中,后者则将数据输出到windows
阅读全文
摘要:NaN (“Not a Number”) means 0/0 NA (“Not Available”) is generally interpreted as a missing value and has various forms – NA_integer_, NA_real_, etc. Th
阅读全文
摘要:RR version 3.1.1 (2014-07-10) -- "Sock it to Me"yum list installed | grep RR-core.x86_64 3.1.0-5.el6 @epel R-core-devel.x86_64 3.1.0-5.el6 @epel R-dev...
阅读全文
摘要:(1)Checking Version of Bioconductor> source("http://bioconductor.org/biocLite.R")Bioconductor version 2.14 (BiocInstaller 1.14.3), ?biocLite for helpA...
阅读全文
摘要:Error in save(filtered, file = paste(sampleName, "filtered", sep = "_")) : error writing to connection (原因:检查路径/权限/剩余空间)
阅读全文
摘要:R gsub Function gsub() function replaces all matches of a string, if the parameter is a string vector, returns a string vector of the same length and ...
阅读全文
摘要:ProblemYou want to do reorder the columns in a data frame.Solution# A sample data framedata id size weight#> 1 1 small 20#> 2 2 large ...
阅读全文