Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>A working example on gitHub</h2> <p><a href="https://github.com/nathanvan/minimalbugexample/tree/e6d62a6da7127fc165332935db04aa88b4575ae6" rel="nofollow">I put a working example on gitHub so that it is easy to browse the different files</a>. </p> <p>FYI, it's not quite a minimal example since it was built with <code>devtools</code>. The "extras" are (1) that <code>roxygen2</code> comments are what builds the NAMESPACE file, and (2) it incorporates unit testing with <code>testthat</code>. All of that can be ignored for the purposes of this example.</p> <h2>The key fix</h2> <p>The short answer that I did, in fact, need to change my NAMESPACE file to: </p> <pre><code>export(make.a.Matrix) export(transpose.a.Matrix) importFrom(Matrix,Matrix) importFrom(Matrix,t) </code></pre> <p>So that R could find the right version of transpose. See this <a href="http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/" rel="nofollow">post</a> for a great description of how R searches for functions. </p> <p>Although not strictly necessary, I modified my DESCRIPTION file to be a tad bit cleaner:</p> <pre><code>Package: minimalbugexample Title: Description: Version: 0.1.3 Author: Nathan VanHoudnos &lt;nathanvan@letterafterFmail.com&gt; Maintainer: Nathan VanHoudnos &lt;nathanvan@letterafterFmail.com&gt; Depends: R (&gt;= 3.0.1), Matrix (&gt;= 1.0) Suggests: testthat (&gt;= 0.7.1.99) License: GPL LazyData: true Collate: 'minimalbugexample-package.r' 'use-Matrix-package.R' </code></pre> <p>Note that I am using <code>Depends:</code> for <code>Matrix</code> instead of <code>Imports:</code> so that the user will be able to use the <code>Matrix</code> objects that the functions return. If this example only used the <code>Matrix</code> stuff internally without presenting it to the user, I'd have used <code>Imports:</code>. </p> <h2>Proof that it works</h2> <pre><code>&gt; require(minimalbugexample) &gt; make.a.Matrix(1:12, 3, 4) 3 x 4 Matrix of class "dgeMatrix" [,1] [,2] [,3] [,4] [1,] 1 4 7 10 [2,] 2 5 8 11 [3,] 3 6 9 12 &gt; transpose.a.Matrix(1:12, 3, 4) 4 x 3 Matrix of class "dgeMatrix" [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9 [4,] 10 11 12 &gt; t( make.a.Matrix(1:12, 3, 4)) 4 x 3 Matrix of class "dgeMatrix" [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9 [4,] 10 11 12 </code></pre> <p>Note that the last command would have failed if I had specified <code>Matrix</code> in <code>Imports:</code> and not <code>Depends:</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload