Write the built-in data set "airquality" to a Tab-separated text file with write.table. View it with a text editor (depending on your system). Change the NA value to . (period), and read the changed file back into R with a suitable command.

 

> write.table(airquality, "02.txt", sep="\t")
 
方法一
> a[is.na(a)]<-"."
> write.table(a, "02_with_period.txt", sep="\t")
> read.table(file = "02_with_period.txt")
 
方法二
> write.table(airquality, na = ".")
> read.table(file = "02.txt" , na.strings = ".")
文章標籤
全站熱搜
創作者介紹
創作者 猛犬 的頭像
猛犬

風中一匹狼

猛犬 發表在 痞客邦 留言(0) 人氣(23)