0

enter image description here

enter image description here

I would like to create a chart where the choice of two data sources makes the difference between the two on the Y-axis.

I wrote this:

ggplot (Values-, aes (x = X, y = (Values $ Y [1] -Values $ Y [2])))

but this (Values $ Y [1] -Values $ Y [2]) makes the difference to me for the first value of the X, but it is the same for all the others.

Where am I wrong?

camille
  • 16,432
  • 18
  • 38
  • 60
  • You shouldn't use the name of the dataframe inside `ggplot` in places like `aes`. Why is there a minus sign after the name of your dataframe? Beyond that, I can't tell what's going on or what you're trying to do unless you `dput` a sample of your data – camille Apr 25 '18 at 01:51
  • the object d must contain the difference between the 2 bars as you can see in the image. I did this    for (i in Values $ Y) {      Values $ Y [i] = Values $ Y [i + 1] - Values $ Y [i + 2]    } but it does not work. alternating with 1 Y contains the values of a type (in total there are 2) – Salvatore Iorio Apr 26 '18 at 07:59
  • the second chart must have only one bar and not the 2 colors .. and it must be the difference between the two – Salvatore Iorio Apr 26 '18 at 08:05
  • It's still unclear what you're doing or what the problem is without seeing the data, and based on the questions I asked in my earlier comment. You should read through [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on how to make an R question that will be easy for folks to help you with – camille Apr 26 '18 at 12:38

0 Answers0