sink() function output result

93 Views Asked by At

I am trying to capture output using sink. At the first, I have tried capture.output() function to stored to .txt file. However, it gives me as following:

[38;5;246m# A tibble: 1 x 7[39m
  .y.   group1               group2                         n1    n2 statistic         p
[38;5;250m*[39m [3m[38;5;246m<chr>[39m[23m [3m[38;5;246m<chr>[39m[23m                [3m[38;5;246m<chr>[39m[23m                       [3m[38;5;246m<int>[39m[23m [3m[38;5;246m<int>[39m[23m     [3m[38;5;246m<dbl>[39m[23m     [3m[38;5;246m<dbl>[39m[23m
[38;5;250m1[39m SP_ER Empire_new_use_cases G9_MWS_Vision_new_use_cases    24    24       300 0.000[4m0[24m[4m1[24m[4m9[24m3

Later, I am using "sink(): function to record the output. However, it gives me the same result on top, and here is the code:

  Wilcoxon_SP_ER <- wilcox_test(task_data_device_all, SP_ER ~ device, paired = TRUE)
  print(Wilcoxon_SP_ER)
  sink(file = paste0(wilcox_result, "/Wilcox_", devices_string, ".txt"))
  print(Wilcoxon_SP_ER)
  sink(file = NULL)

I am trying to record/stored the same output as using print() function. Like following:

# A tibble: 1 x 7
  .y.   group1               group2                         n1    n2 statistic         p
* <chr> <chr>                <chr>                       <int> <int>     <dbl>     <dbl>
1 SP_ER Empire_new_use_cases G9_MWS_Vision_new_use_cases    24    24       300 0.0000193

How can I fix this? Thanks!

0

There are 0 best solutions below