title: How to create outputs in list form that aren't shown as lists & how to print only part of the result
body: <p>Many functions' outputs come in the list structure - for example lm(). As a result, you can retrieve the separate section of the output using "$" or indexation with square brackets. My question is how I can create an output in list form, without overtly showing that it is a list. As you know, when a list is printed on the screen, it typically has the sub-list name or index indicated, such as below:</p>
  
  <pre><code>L1 = list(a=1:3, b=letters[1:3])
  L1
  
  $a
  [1] 1 2 3
  
  $b
  [1] "a" "b" "c"
  </code></pre>
  
  <p>However, lm() output never shows the different sub-lists using "$" and sub-list names - although you can extract these sub-lists using "$" and sub-list names.</p>
  
  <p>A second question pertains to the fact that some functions' outputs include much more than what is actually printed on the screen (e.g., lm(), again). If we use str() for the fitted model, we will see a whole bunch of content within the fitted model most of which is not printed. How is this achieved? Does the function print something and output something else (using invisible()) separately like below?</p>
  
  <pre><code>foo = function(x){
     result = list(data=x, test.result=t.test(x))
     print(result[[2]])
     invisible(result)
  }
  foo(1:10)$data
  </code></pre>
  
  <p>Thanks!</p>