Misspecify Argument

I am trying to make a simple bar chart plot using ggplot and it was running smoothly before but now I get this "misspecify argument" error:

Error: 2 components of `...` had unexpected names.

We detected these problematic arguments:
* `x`
* `fill`

Did you misspecify an argument?

I know there is nothing wrong with my code bc it use to successfully plot the bar chart needed.

I am using R 4.1

PLEASE HELP!

Please post the ggplot code you are using. Even better, include the code to make a small data frame and the ggplot call that produces the error when you try to plot that data frame.

Month <- c(1,2,3)
Frequency <- c(100,200,300)
df <- data.frame(Month,Frequency)

ggplot(df, aes(x=Month, y=Frequency)) + geom_bar(stat="identity")

I found this thread on stackoverflow and its basically my problem except dplyr is claiming i have misspecified argument. : r - dplyr select is claiming that I have extra arguments that are not there - Stack Overflow

Your code does run without error for me.
The thread you link to in Stack Overflow suggests the problem appears after installing new packages. Did you do that between the time your code worked and when it started to fail?

yeah I think I did install some new packages. I also did an update of R and all my existing packages. any idea on how I can try to resolve this?

I already tried following the suggestion on Stack Overflow to install the dev version of dplyr but still no success...

thanks so much for your help

Have you tried running

rlang::last_error() 

immediately after the error? You may have to install the rlang package. Note which packages are mentioned in the output and reinstall those. I am simply repeating what the SO thread suggests but it seems like a reasonable path.

Okay, when I run rlang::last_error() this is what I get

<error/rlib_error_dots_named>
2 components of `...` had unexpected names.

We detected these problematic arguments:
* `x`
* `y`

Did you misspecify an argument?
Backtrace:
 1. ggplot2::ggplot(df, aes(x = Month, y = Frequency))
 3. tidyr:::aes(x = Month, y = Frequency)
 4. ellipsis::check_dots_unnamed()
 5. ellipsis:::action_dots(...)

I also ran rlang::last_trace() and get this:

<error/rlib_error_dots_named>
2 components of `...` had unexpected names.

We detected these problematic arguments:
* `x`
* `y`

Did you misspecify an argument?
Backtrace:
    x
 1. +-ggplot2::ggplot(df, aes(x = Month, y = Frequency))
 2. +-ggplot2:::ggplot.default(df, aes(x = Month, y = Frequency))
 3. \-tidyr:::aes(x = Month, y = Frequency)
 4.   \-ellipsis::check_dots_unnamed()
 5.     \-ellipsis:::action_dots(...)```

I would start with using uninstall.packages() to remove ggplot2 and tidyr and then reinstall them. Do let us know if that works. I have not seen this problem before.

Still not working, i uninstalled and reinstalled ggplot2 and tidyr and was still unable to run a simple bar chart plot (per the simple dataframe of month and frequency code i have above)

There is still the ellipsis package to try reinstalling.

still no luck, i uninstalled ellipsis and then reinstalled it and still getting the same traceback error. are you also using R 4.1?

(update) I have also tried uninstalling all of R and R studio and reinstalling everything completley so now all of my packages are newly installed and the most updated. but i still have the same error.... could this possibly be an error with the version 4.1.0 of R?

After you run the code that reproduces this error. What happens if then next do
getAnywhere(aes)

This is what I got if I enter getAnywhere(aes):

2 differing objects matching β€˜aes’ were found
in the following places
  .GlobalEnv
  package:ggplot2
  namespace:ggplot2
Use [] to view one of them

thats good, I think therefore the trace is misleading in at least that tidyr::: doesnt have an aes function in the name space. but sorry, it doesnt tell me how to solve your issue.

Hello and welcome to the forum!

I've also tried running your code and it works for me:

library(ggplot2)

Month <- c(1,2,3)
Frequency <- c(100,200,300)
df <- data.frame(Month,Frequency)

ggplot(df, aes(x=Month, y=Frequency)) + geom_bar(stat="identity")

image

sessionInfo()
#> R version 4.0.4 (2021-02-15)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggplot2_3.3.2
#> 
#> loaded via a namespace (and not attached):
#>  [1] xml2_1.3.2        knitr_1.30        magrittr_2.0.1    tidyselect_1.1.0 
#>  [5] munsell_0.5.0     colorspace_2.0-0  R6_2.5.0          rlang_0.4.11     
#>  [9] httr_1.4.2        dplyr_1.0.2       stringr_1.4.0     highr_0.8        
#> [13] tools_4.0.4       grid_4.0.4        gtable_0.3.0      xfun_0.19        
#> [17] withr_2.3.0       htmltools_0.5.1.1 ellipsis_0.3.1    yaml_2.2.1       
#> [21] digest_0.6.27     tibble_3.0.4      lifecycle_0.2.0   crayon_1.3.4     
#> [25] farver_2.0.3      purrr_0.3.4       vctrs_0.3.5       curl_4.3         
#> [29] mime_0.9          glue_1.4.2        evaluate_0.14     rmarkdown_2.5    
#> [33] labeling_0.4.2    stringi_1.5.3     compiler_4.0.4    pillar_1.4.7     
#> [37] generics_0.1.0    scales_1.1.1      pkgconfig_2.0.3

As you can see I am using R version 4.04. Have you tried downgrading?

Also, why is there an 'aes' object in the global environment? Maybe it doesn't matter, but I am just seeing one object when I run getAnywhere(aes):

> getAnywhere(aes)
A single object matching β€˜aes’ was found
It was found in the following places
  package:ggplot2
  namespace:ggplot2
with value

function (x, y, ...) 
{
    exprs <- enquos(x = x, y = y, ..., .ignore_empty = "all")
    aes <- new_aes(exprs, env = parent.frame())
    rename_aes(aes)
}
<bytecode: 0x7fae89af68f8>
<environment: namespace:ggplot2>

thats a good catch. the original poster may have accidently created a competing aes() function that conflicts with that provided by ggplot2. I didnt notice it when looking at their post !

The OP says

Can they be reloading an old workspace automatically?

Note: Code works for me with R 4.1.1 & RStudio 1.4.1714 , Ubuntu 21.04

thanks so much for your reply. can you explain a little more about the "aes" object in the global environment comment? Im confused as to what you mean.... I thought aes was part of the argument for a ggplot function.