I have a data set which I read from my a .csv file. After some editing work, I now need to write it as a .txt file with (i) all quotes removed (ii) every NA
in the whole file to be replaced by an asterisk, *
, and (iii) first row (variable names) excluded.
The following scripts, so far, remove quotes and am just wondering how can (ii) and (iii) can be added or may be done.
write.table(ped5, "ped5.txt" ,row.names=FALSE)
ped5 <- read.table("ped5.txt", header=TRUE)
write.table(ped5, "ped7.txt", row.names=FALSE, quote=FALSE)
Any help would be very much appr开发者_如何学Ceciated!
For (ii) use na = "*"
and for (iii) col.names=FALSE
.
So:
write.table(ped5,"ped7.txt",row.names=FALSE,quote=FALSE, na="*", col.names=FALSE)
It's all to find on help page to write.table
(?write.table
).
精彩评论