Giter VIP home page Giter VIP logo

Comments (1)

winterstat avatar winterstat commented on August 12, 2024

After trying simply commenting out that one line in the ggcorr function, I now know that 0s are replaced by NA to get the upper triangle of the correlation plot to be empty. As a fix for myself, I tried the following.

#m <- data.frame(m * lower.tri(m))
  # replace above with this: 
  m[upper.tri(m, diag = T)] <- NA
  rownames(m) <- colnames(m)
  
  # need to make it a dataframe:
  m <- data.frame(m)
  m$.ggally_ggcorr_row_names <- rownames(m)
  # m = reshape::melt(m, id.vars = ".ggally_ggcorr_row_names")
  # names(m) = c("x", "y", "coefficient")
  m_long <- m %>%
    tidyr::pivot_longer(
      cols = -.ggally_ggcorr_row_names,
      names_to = "y",
      values_to = "coefficient"
    ) %>%
    dplyr::rename(x = .ggally_ggcorr_row_names) %>%
    dplyr::mutate(y = factor(y, levels = rownames(m)))
  
  #m_long$coefficient[m_long$coefficient == 0] <- NA

This works for me, but I'm not a great R programmer, so if someone else has a more elegant solution please use that instead.

Edited to add:

Could I also suggest using label = format(label, nsmall = label_round) in several places in the ggcorr function to ensure that rounding is consistent (e.g., "0.00" shows up as "0.00" not "0")?

from ggally.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.