4

When compiling to pdf through Sweave, we are unable to have the output of user defined functions wrap text, instead they run off the page and are not readable. Example code of output similar to one of the user defined functions is given below.

We are looking for a solution in Sweave where we can call the function and have the output wrap within the margins of the pdf. If possible, we would like to avoid editing the function itself.

\documentclass{article}

\begin{document}
\SweaveOpts{concordance=TRUE}

<<>>=
long_output <- function(x,group){
  var1 <- paste0(group, "_", x, ".devcmn")
  var2 <- paste0(group, "_", x, ".cmn")
  resNames <- c(var1,var2)
  class(resNames) <- "long_output"
  return(resNames)
}

print.long_output <- function(x){
  cat("The following variables (group summary, deviation) were added to the dataset:", x[1], x[2], '\n')
  cat("See package documentation for detailed description of variables added.")
}

long_output("Variable","Grouping")
@

\end{document}

We have tried the solutions on the following pages with no success:

0 Answers0