johnl
johnl

Reputation: 310

Sudden "unused argument" error

I have no idea why but I am quite sure the following did produce a plot a while back. Can you tell me what's wrong here?

library(ggplot2)
qplot(c(0, 2), stat="function", fun=exp, geom="line") 

This returns "Error in c(0, 2) : unused argument (2)." Why?

Edit: This is a general problem:

a <- c(0, 2)

gives the same error. What's going on here?

Upvotes: 7

Views: 35306

Answers (2)

Hafeez
Hafeez

Reputation: 95

I faced the same problem with textnets package even though the same code worked fine several months ago.

https://github.com/cbail/textnets

In my case, turns out, Bail had changed the function names and arguments, so some of the previous arguments are no longer valid! Just check which arguments the function currently takes.

Upvotes: 0

Ben Bolker
Ben Bolker

Reputation: 226881

Works for me with ggplot2 v 0.9.3.1. Based on your edit, I'm 99% sure you have a different c() function defined in your workspace/loaded somewhere in your search path (getAnywhere("c")$where), which is masking the built-in version.

To test, try starting from a clean session (with --vanilla if possible to skip reloading workspace/executing .Rprofile/etc.)

If you're lucky the problem is in your global workspace and rm("c") will work -- otherwise you have to track down which package is loading this booby trap ... (find("c") could be useful in that case ...)

Upvotes: 13

Related Questions