[R] length of 'dimnames' [2] not equal to array extent- For Correlation Plot

Sarah Goslee sarah.goslee at gmail.com
Sat Mar 17 16:15:46 CET 2018


I'm assuming you are using the corrplot package.

If so, your data object does need to be a matrix, not a data frame.
Since it's already a data frame, your line of code:

as.matrix(as.data.frame(CR1))

doesn't need the as.data.frame function, but more importantly, you
didn't assign the result to anything: as.matrix() does not work in
place.

CR1 <- as.matrix(CR1)

Now try.

If that doesn't work, then provide a reproducible example so we can
offer further advice.

Sarah

On Sat, Mar 17, 2018 at 11:08 AM, Shivi Bhatia <shivipmp82 at gmail.com> wrote:
> Created a new data set with 3 numeric variable to find correlation
>
> CR1<- mar%>%  as_data_frame%>%  select(AGE, OLD_CAR_PURCHASE_YRS,
> Total.Spend.With.AA)
>
> had to convert it to a data frame, code:
>
> as.matrix(as.data.frame(CR1))
>
> Now i need to run a correlation plot for these 3 variables:
>
> corrplot(CR1, method = "circle")
>
> But i am getting this error:
> Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow =
> nr, : length of 'dimnames' [2] not equal to array extent
> Researched and found Correlation
> <https://stackoverflow.com/questions/43362420/length-of-dimnames-2-not-equal-to-array-extent-when-using-corrplot-function>that
> corrplot requires a matrix however the error is still the same.
> Regards, Shivi
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list