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 appreciated!
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With