Reputation: 75
Am trying to write a summary onto excel using text file. Here is the example of how it looks like in R output.
[1] "\n\nDuring the post-intervention period, the response variable had an average value of approx.196.08K. In the absence of an intervention, we would have expected an average response of 199.41K.
However, when i write this to a text file using write.table this is how the text file looks like
*During the post-intervention period, the response variable had an average value of approx.196.08K.
In the absence of an intervention, we would have expected an average response of 199.41K.*
Here is the code am using for this.
write.table(analysis_text, file = "analysis_text.txt", sep = "",
row.names = TRUE, col.names = NA)
Is there anyway i can ignore "/n" while writing into txt file in R?
Upvotes: 0
Views: 629
Reputation: 101818
If you want to ignore "\n", maybe you can do some pre-processing on your analisys_text
, i.e., gsub("\n","",analisys_text)
, which removes "\n" in your texts.
In this sense, you code should be like
write.table(gsub("\n","",analisys_text),
file = "analysis_text.txt",
sep = "",
row.names = TRUE,
col.names = NA)
Upvotes: 1
Reputation: 22225
Looking at the write.table
help, the function can also take an eol
argument, which defaults to \n
.
Change that to eol=""
and you should be fine.
Upvotes: 0