1

I'm using asreml-R package for my analysis. Whenever I stored a fitted model object asreml-R gives some extra information which I want to hide. See the code and the information below:

library(asreml)
dat <- data.frame(y=rnorm(20),x=seq(1,20))
ex.asr <- asreml(y ~ x, data=dat)

asreml(): 3.0.1 Library: 3.01gl IA32  Run: Wed May 30 13:26:44 2012

     LogLik         S2      DF
    -11.3850      0.7691    18  13:26:44
    -11.3850      0.7691    18  13:26:44

Finished on: Wed May 30 13:26:44 2012

LogLikelihood Converged 

I would highly appreciate if you help to hide this extra information. Remember that asreml-R is not an open source. Thanks

Kevin Wright
  • 2,397
  • 22
  • 29
MYaseen208
  • 22,666
  • 37
  • 165
  • 309

3 Answers3

4

use asreml's controlling stuff - the asreml.control() function control many aspects of asreml call, you can provide its arguments directly to asreml call, in you case you want to have trace=F, so e.g.

library(asreml)
dat <- data.frame(y=rnorm(20), x=seq(1,20))
ex.asr <- asreml(y ~ x, data=dat, trace=F)
szymekD
  • 61
  • 4
2

If (as it appears) that is something that is being print()'ed, you can use capture.output() to sink it to a temp file.

Here's an example:

plot(rnorm(99))

capture.output({
    lapply(1:4, function(X) abline(v=20*X))
}, file = tempfile())

## Here's the output that was sunk by `capture.output()`
## (wrapping the call in `suppressMessages()` won't get rid of those "NULL"s)
lapply(1:4, function(X) abline(v=20*x))
[[1]]
NULL

[[2]]
NULL

[[3]]
NULL

[[4]]
NULL
Josh O'Brien
  • 159,210
  • 26
  • 366
  • 455
2

if asreml-R is well designed then putting suppressMessages() around the command should work. Otherwise I would suggest

sink("junk.txt")
## asreml command
sink()
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • Thank @Ben for your answer. `suppressMessages()` does not work with `asreml-R`. I will try your other suggestion. Thanks – MYaseen208 May 30 '12 at 18:53
  • 1
    Nice alternative. I like the bit of `?capture.output` that reads: "[‘capture.output is’] related to ‘sink’ in the same way that ‘with’ is related to ‘attach’. – Josh O'Brien May 30 '12 at 18:57
  • Using `sink()` also gives the message in the output document. – MYaseen208 May 30 '12 at 19:02
  • The messages from asreml-r are sent to the screen by the Fortran code in the dll, so not directly controllable by R. Use the 'asreml.control' function described below. – Kevin Wright Mar 27 '14 at 18:16