0

I made this code:

tiff("C:/Users/grego/OneDrive/Documentos/Meat_grades/Brazil_Beef_Quality/Bianca/lab_corr_geral.tiff", width =10 , height = 6, units = 'in', res = 200)
    corr.data(final[c(14:24, 52:55)]) %>% 
      ggplot(aes(fct_relevel(colvars,'pH','PL','DL','EL','CL','L*','a*','b*','c*','h*','WBSF','TE','JU','FL','OA'), 
                 fct_relevel(rowvars,'pH','PL','DL','EL','CL','L*','a*','b*','c*','h*','WBSF','TE','JU','FL','OA'))) +
      geom_tile(colour="grey20", aes(fill=corr), size=0.5) +
      #geom_point(aes(size=p.value, colour=cut(abs(corr), c(0, 0.01, 0.05, 1), include.lowest=TRUE)), pch=15) +
      geom_text(aes(label=sprintf("%1.2f", corr)), position=position_nudge(y=0.2), 
                size=2.5, colour="black") +
      geom_text(aes(label=paste0("(",sprintf("%1.2f", p.value),")")), position=position_nudge(y=-0.2), 
                size=2, colour="black") +
      scale_fill_gradient2(low="red", mid="yellow2", high="blue", midpoint=0, limits=c(-1,1)) +
      scale_size_continuous(range=c(8,12)) +
      labs(x="",y="") +
      theme (axis.text = element_text(size = 10), legend.position = "none") +
      coord_fixed()
    dev.off()

and I got this graph:

enter image description here

and I got This error:

Joining with `by = join_by(rowvars, colvars)`
Warning messages:
1: 5 unknown levels in `f`: L*, a*, b*, c*, and h* 
2: 5 unknown levels in `f`: L*, a*, b*, c*, and h* 
3: 5 unknown levels in `f`: L*, a*, b*, c*, and h* 
4: 5 unknown levels in `f`: L*, a*, b*, c*, and h* 

The label names are the same in my dataset. So the graph is ok for col label (L*, a*, b*, c*, and h*), but the row label are wrong (L., a., b., c., and h.). Some suggestion?

r2evans
  • 141,215
  • 6
  • 77
  • 149
Greg Rov
  • 327
  • 3
  • 12
  • 2
    Are you able to make this question [reproducible](https://stackoverflow.com/q/5963269)? This seems sensitive to things like factor levels and such where it would be much simpler with actual data. For "minimal" reprex, it might be sufficient to reduce this to (say) 4x4 with the same error if possible. – r2evans May 24 '23 at 18:56
  • 1
    My bad, I will do this. – Greg Rov May 24 '23 at 19:02

0 Answers0