Reputation: 2283
I have the following dataframe (data6):
1 41595370 1 1 OV1
2 41595371 1 1 OV2
3 41595282 1 1 OV3
4 41595282 2 1 OV3
I would like to write it to txt file that all of the lines are in one line like this (i.e. no space separator between each row and space between each column):
41595370 1 1 OV141595371 1 1 OV241595282 1 1 OV341595282 2 1 OV3
When I use the following command:
write.table(data6, "C:/MyData.txt", eol="", quote=F)
I get it with spaces between each row/ line) like this: 41595370 1 1 OV1 41595371 1 1 OV2 41595282 1 1 OV3 41595282 2 1 OV3 How can I omit the space between each row/ line?
Upvotes: 0
Views: 204
Reputation: 31181
You can proceed with:
cat(paste(apply(t(df), 2, paste, collapse=' '),collapse=''), file='blob.txt')
#[1] "41595370 1 1 OV141595371 1 1 OV241595282 1 1 OV341595282 2 1 OV3"
Upvotes: 2