How to save t.test result in R to a txt file?

6.8k Views Asked by At

I have got an output like this( t test output)

enter image description here

I want to combine them. But it came like this. Values are same only but not in the above format. enter image description here

How can we save all of them in a txt format in the first mentioned format?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use capture.output to print the objects and save the output into a character vector:

chars <- capture.output(print(t_SVI_Chennai), print(t_SVI_Mumbai))

You can then write it to a file with writeLines, such as:

writeLines(chars, con = file("output.txt"))