Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Formal argument "foo" matched by multiple arguments" - how to deal with this in R?
    primarykey
    data
    text
    <p>Sometimes, calling a function with certain arguments results in the error message <code>formal argument "foo" matched by multiple actual arguments</code>. Is it possible to print the list of the ambiguous actual arguments?</p> <p>The reason I'm asking this is currently a problem with the <code>plot</code> function for objects of class <code>mixEM</code> (generated by <code>normalmixEM</code> from the <code>mixtools</code> package). It doesn't accept the argument <code>ylim</code> yielding the error above, but when I try to use <code>ylim2</code> (the way it works for <code>xlab2</code>, <code>main2</code>, <code>col2</code> etc.), it says <code>"ylim2" is not a graphical parameter</code>. So I wonder what are the actual arguments that are matched by <code>ylim</code>?</p> <p>Using <code>formals(plot.mixEM)</code> doesn't help because it doesn't contain anything starting with <code>ylim</code>, but then at the end it refers to <code>...</code> which are the graphical parameters passed to <code>plot</code>. However, for the <code>plot</code> function, <code>ylim</code> would be unambiguous. Getting a more exact error description from <code>R</code> with a list of the conflicting arguments would be helpful.</p> <p>UPD: MWE:</p> <pre><code>library(mixtools) wait = faithful$waiting mixmdl = normalmixEM(wait) plot(mixmdl, which = 2, xlim = c(25, 110), nclass=20) lines(density(wait), lty = 2, lwd = 2) </code></pre> <p>This produces an error:</p> <pre><code>plot(mixmdl, which = 2, xlim = c(25, 110), ylim = c(0, .5), nclass=20) # Error in hist.default(x, prob = TRUE, main = main2, xlab = xlab2, ylim = c(0, : # formal argument "ylim" matched by multiple actual arguments` </code></pre> <p>This simply doesn't work:</p> <pre><code>plot(mixmdl, which = 2, xlim = c(25, 110), ylim2 = c(0, .5), nclass=20) # Warning messages: # 1: In title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...) : # "ylim2" is not a graphical parameter # 2: In axis(1, ...) : "ylim2" is not a graphical parameter # 3: In axis(2, ...) : "ylim2" is not a graphical parameter </code></pre>
    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.
 

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