title: How can I use sink and still get messages printed in R?
body: <p>I am trying to save the log of a boosting using <code>sink</code> function, as following code:</p>
  
  <pre><code>require(xgboost)
  require(R.utils)
  
  data(iris)
  train.model &lt;- model.matrix(Sepal.Length~., iris)
  
  dtrain &lt;- xgb.DMatrix(data=train.model, label=iris$Sepal.Length)
  
  xgb_grid = list(eta = 0.05, max_depth = 5, subsample = 0.7, gamma = 0.3,
    min_child_weight = 1)
  
  sink("evaluationLog.txt")
  fit_boost &lt;-xgb.cv(data  = dtrain,
                    nrounds     = 1000,
                    objective   = "reg:linear",
                    eval_metric = "logloss", 
                    params = xgb_grid,
                    colsample_bytree = 0.7, 
                    early_stopping_rounds = 100,
                    nfold = 5,
                    prediction = TRUE,
                    maximize = FALSE
                    )
  
  sink()
  </code></pre>
  
  <p>However I can't see "what's happening" since it's not printing the function's output and/or message.</p>
  
  <p>My question is how can I can retrieve both a <code>.txt</code> file with <code>sink</code> and see what the function (in this case would be <code>xgb.cv</code>) is printing?</p>
  
  <p>Thank you!</p>