Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:02:00+00:00 2026-06-12T09:02:00+00:00

I am trying to create a heatmap in R. I have tried using the

  • 0

I am trying to create a heatmap in R. I have tried using the heatmap.2 command.

My data consists of x, and y columns and associated relative frequency of a point(frequency divided by the total frequency)

with zero frequency in most places and a small relative frequency in others. I have converted my data to a matrix since this seems what the heatmap command wants and attempted to remove the x and y-coordinates.

BB <- matrix(as.matrix(surfacerevfreq1[, 3]),  ncol = 35, byrow = T)

There are two problems as I see it, not all x and y -coordinates are listed. i.e. the x-coordinate starts at 1 and goes to 35 whereas the y-coordinate starts at 11 and goes to 30. The heatmap function does not seem to like this. I have thought over inserting zeros at the beggining of the data set so that each point from 1- 10 on the y-axis had a value. However, I am not sure if this is the best idea.

So I suppose my question is: how do I format my data in such a way that I can a valid heatmap from this data? I should add that I want the numbers on my x and y-scale displayed also if possible. Since the purpose it to graphically show the relative frequency associated with each point.

thanks.

here is a subset of my data so that you can see what it looks like in matrix form

    col1         col2         col3         col4         col5         col6            col7         col8         col9        col10        col11        col12 
0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000    0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 
   col13        col14        col15        col16        col17         col18            col19        col20        col21        col22        col23        col24 
0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000  0.0000000000 0.0000000000 0.0000000000 0.0005017561 0.0005017561 0.0000000000 
   col25        col26        col27        col28        col29            col30            col31        col32        col33        col34        col35 
0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000      0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 

and here is the heatmap command that I am using:

hU <- heatmap.2(xx, Rowv=FALSE, symm=TRUE,  trace="none", density.info="none",   dendrogram="none")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:02:01+00:00Added an answer on June 12, 2026 at 9:02 am

    Try this, considering your 3 columns data is stored in data[x, y, q]

    a = matrix(0, nrow = 30 - 10, ncol = 35)
    rownames(a) = 11:30
    apply(data, 1, function(x) a[x[2] - 10, x[1]] <<- x[3])
    heatmap.2(a, Rowv=FALSE, symm=TRUE,  trace="none", density.info="none", 
              dendrogram="none", xlab="X", ylab="Y")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi I'm trying create chat using node.js I see example in http://chat.nodejs.org/ I have
I am trying to create a heatmap from some static data. The data has
I am trying create a data.frame from which to create a graph. I have
I am trying to create a simple heatmap in R, using a diverging colour
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
All, I am trying create a 'to & fro' animation using jquery animate &
I'm trying create a gui using Tkinter that grabs a username and password and
I'm trying create a connection using Spring 3.2.0 but I get NullPointerException of: ApplicationContext
I'm trying create an executable for Windows for a GUI application in tkinter using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.