1

Hey there I got a quick question,

I have the following extract of my dataset:

head(meanchangeafterdowngrade)
    `Days after downgrade` `CDS-bond basis` `Basis change                                                 
                    <dbl>            <dbl>         <dbl>
1                    -30        -27.41164     0.02152773
2                    -29        -27.13952     0.01377565
3                    -28        -27.12704     0.02781917
4                    -27        -27.10034     0.02570149
5                    -26        -27.10408     0.02681551
6                    -25        -27.10054     0.02795637

Now I would like to plot the "Days after downgrade" on the x-axis and the other 2 variables on the y-axis using ggplot. I achieved to plot them in two separate graphs, however I would like to have them in the same. I guess I should use the melt() function, but I did not quite get it yet.

1 Answer 1

3

Here is an example with the iris dataset:

library(ggplot2)

dat <- reshape2::melt(iris, id.vars="Species", 
                      measure.vars=c("Sepal.Length", "Sepal.Width"))

ggplot(dat, aes(x=Species, y=value, color=variable)) + 
  geom_point()

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.