Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

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?

like image 467
Abdul Shiyas Avatar asked Oct 21 '25 11:10

Abdul Shiyas


1 Answers

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"))
like image 62
David Robinson Avatar answered Oct 23 '25 02:10

David Robinson