苑黎

导航

 

对于小数据:用键盘输入数据、

> mydata<-data.frame(age=numeric(0),gender=character(0),weight=numeric(0))
> mydata<-edit(mydata)

就会出现一个文本编辑器

读入文本文件

scan(file,what=" "(如有字符“charactor”和数字"number"必须有),sep="\n"(表示以行来读取))-----用于读取多行文本

readline(prompt = "")----------用于一行读取

读取带分隔符的数据

read.table(file,header=logical_value,sep=","("\t"," ","\n",还可以自己设置分隔符),row.name=,colclasses=为每一列指定一个类(logical,numeric,character,factor))

If the fi rst line of your input le contains the names of the variables in your data separated
with the same separator used for the rest of the data, you can pass the header=TRUE argument

read.csv()  read.delim()

输出

 

write.table(x,file)

 

posted on 2016-03-19 17:09  苑黎  阅读(456)  评论(0编辑  收藏  举报