I have two dataframes, one with some sensory data, and some with some analytical data. I want to see if there are any correlations between any of the analytical data and the sensory data, so basically a correlation matrix across all values in each dataframe. But then I want to be able to plot these as a heatmap.
and this gave me a matrix. But then I'm having trouble formatting a geom_tile plot with aesthetics from here, getting the error:
> ggplot(cordata2, aes(x=sensory,y=analytical))+
+ geom_tile()
Error in `fortify()`:
! `data` must be a <data.frame>, or an object coercible by `fortify()`, not a
double matrix.
Run `rlang::last_trace()` to see where the error occurred.
I'm not sure how to fix this. If anyone could advise, that would be great.
The cor function returns a matrix and ggplot() needs a data.frame. Here is an example with some toy data. I also included a plot made with the corrplot package, which you may find useful. There are many options for plotting in corrplot.
Notice the order of the y axis is different in the two plots.