基础知识
- R的赋值<-
- R的代码都是带英文括号
- 表格在R语言中叫数据框
- ?read.table,调出相应函数的帮助文档,翻到example部分研究一下。或者直接网页搜索你不会的函数。
标量与向量的区分
向量的赋值与提取
数据框
- 导入read.table(file = "huahua.txt",sep = "\t",header = T);x<-read.csv("doudou.txt")
- 列名colnames(X)
- 行名rownames(X)
- 导出write.table(X,file = "yu.txt",sep = ",",quote=F)
- 保存save.image(file="bioinfoplanet.RData")#保存当前所有变量
save(X,file="test.RData")#保存其中一个变量 -
加载load("test.RData")#再次使用RData时的加载命令
-
提取元素
含义
header
a logical value indicating whether the file contains the names of the variables as its first line. If missing, the value is determined from the file format: header is set to TRUE if and only if the first row contains one fewer field than the number of columns.
sep
the field separator character. Values on each line of the file are separated by this character. If sep = "" (the default for read.table) the separator is ‘white space’, that is one or more spaces, tabs, newlines or carriage returns.
quote
the set of quoting characters. To disable quoting altogether, use quote = ""
. See [scan](http://127.0.0.1:44515/help/library/utils/help/scan)
for the behaviour on quotes embedded in quotes. Quoting is only considered for columns read as character, which is all of them unlesscolClasses
is specified.
问题
save(X,file="test.RData")这句代码如果报错X not found,是为什么,应该怎么解决?
X数据没有保存或者提取出来,重新读X这个数据或者重新提取X。