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 6474209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:33:37+00:00 2026-05-25T06:33:37+00:00

I have a data frame with three columns and I’d like to make a

  • 0

I have a data frame with three columns and I’d like to make a image/heatmap of the data.

The three columns are pe, vix, and ret with pe and vix being x and y and ret being z.

There are 220 lines in the data frame so i’d like to bin the data if possible, the ranges are below.

Any suggestions for how to bin the x and y data and also create a matrix for use in an image()?

> range(matr$pe)
[1] 13.32 44.20
> range(matr$vix)
[1] 10.42 59.89
> range(matr$ret)
[1] -0.09274936  0.04693118
> class(matr)
[1] "data.frame"
> head(matr)
     pe   vix          ret
1 20.86 13.16 -0.002931561
2 20.46 12.53 -0.003546889
3 20.52 12.42  0.006339165
4 20.61 13.47  0.009683174
5 20.57 11.26 -0.002666668
6 20.81 11.73  0.002895003
  • 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-05-25T06:33:37+00:00Added an answer on May 25, 2026 at 6:33 am

    Here’s what I ended up doing. I used the interp() function in the akima package to create the appropriately binned matrix object. It seems to do the work of binning and ‘matricizing’ of the data frame. On a side note, in order to make the heatmap WITH a legend, I ended up using the image.plot() method from the fields package. Here’s the
    code:

    par(bg = 3)
    image.plot(s,xlab="P/E Ratio", ylab="VIX", 
        main="Contour Map of SPY Returns vs P/E Ratio and Vix") 
    abline(v=(seq(0,100,5)), col=6, lty="dotted") 
    abline(h=(seq(0,100,5)), col=6, lty="dotted") 
    contour(s, add=TRUE)
    

    and resulting product for anyone interested:
    enter image description here

    Thanks to everyone for their help and suggestions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three variables in a data frame and would like to swap the
While data frame columns must have the same number rows, is there any way
I have a data frame that is 100 X 100. There are 30 columns
I have a data frame where columns are constantly being added to it. I
I have a data.frame with 2 columns: Node A, Node B. Each entry in
I have a data frame with two columns. First column contains categories such as
I have a data frame with gaps like this: Var1 Var2 Var3 1 NA
I have a data.frame in R that looks like this: score rms template aln_id
Suppose that you have a data frame with many rows and many columns. The
In R, I have a data frame with columns for Seat (factor), Party (factor)

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.