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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:01:56+00:00 2026-05-28T20:01:56+00:00

I just got introduced to quantmod, and looked at examples here http://www.r-chart.com/2010/06/stock-analysis-using-r.html I tried

  • 0

I just got introduced to quantmod, and looked at examples here
http://www.r-chart.com/2010/06/stock-analysis-using-r.html
I tried the following code,

getSymbols(c("^GSPC","^VIX"))
head(as.xts(merge(GSPC,VIX)))
chartSeries(c(GSPC, VIX), subset='last 3 months')

but the graph was completely out-of-scale, so I hope some of the experts on this forum can show me how to plot this correctly.

  • 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-28T20:01:59+00:00Added an answer on May 28, 2026 at 8:01 pm

    Here is an example that does not use chartSeries.

    ind <- function(x) {
      # Divide each column by the first non-NA value
      # (There may already be a function to do that.)
      coredata(x) <- t(t(coredata(x)) / apply(coredata(x),2,function(u){ c(u[!is.na(u)&u!=0],NA)[1] }))
      x
    }
    x <- cbind( Ad(GSPC), Ad(VIX) )
    x <- x["2011-11::"]
    
    # Using base graphics
    matplot( 
      index(x), coredata(ind(x)), 
      xlab="", ylab="", main="",
      type="l", lty=1, lwd=3, axes=FALSE 
    )
    abline(h=1, lty=3, col="lightgrey")
    axis(2, las=1)
    axis.Date(1, index(x))
    box()
    legend( "topleft", gsub("\\..*", "", names(x)), lty=1, lwd=3, col=1:2 )
    
    # If you prefer ggplot2
    library(ggplot2)
    library(reshape2)
    d <- data.frame( date = index(x), coredata(ind(x)) )
    names(d) <- gsub("\\..*", "", names(d))
    d <- melt(d, id.vars="date")
    ggplot(d, aes(date, value, color=variable)) + geom_line(size=2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In school we just got introduced to the binary search algorithm. However, in our
just got a slight problem here with updating a MySql DataGridView from visual studio
I just got the hang of using the Editor framework and am porting over
Just got into using Screen for remote pair-programming purposes with Vim. Was wondering if
Just got a question about generics, why doesn't this compile when using a generic
Just got the new iPad, and when I touch the microphone and say a
i just got a call from Hosting company, they claimed that my application creates
I just got an email from twitter saying my keys have now been enabled
I just got pagination to work on my site, but I wanted to use
I just got a job offer to be a FE Developer, but I've never

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.