[R] Issue with var command in stats package

David Winsemius dwinsemius at comcast.net
Sun Mar 27 18:28:50 CEST 2016

> On Mar 27, 2016, at 9:14 AM, John, Larry <Larry.John at anser.org> wrote:
> Am using R version 3.2.4 in a fully updated version of Windows 7 and the most current versions of coorplot, FactoMineR and factoextra to support multiple correspondence analysis. However, today, a line of code that worked just fine on one set of data produced an error message on a different set of data.
> Specifically, when I ran:
> corrplot(var$contrib, is.corr = FALSE)
> I received the following message:
>> corrplot(var$contrib, is.corr = FALSE)
> Error in var$contrib : object of type 'closure' is not subsettable

Since there is apparently not an object in your workspace named `var`, the interpreter is instead finding the function named `var` (which delivers the variance of a vector) and then is trying to apply the `$`-function to it .... but there is no `$`-method for functions. 

> Can you please tell me what this error message means and roughly what I might need to do to correct it? If necessary, I can provide the original data files.

I doubt that the error is in your data. You need to find the section of code that was supposed to be creating an object named `var` and hopefully you now understand why that naming convention was a bad idea. Rewrite that section of code to use objects having more meaningful names, which will result in errors that are more helpful to you in the future.


David Winsemius
Alameda, CA, USA

More information about the R-help mailing list