1
votes

I am facing some issues with using 'ggplot' function. I have the data table (Crop_cond) as shown in the image. I am using the following code to obtain a bar plot as shown in the image below.

I was able to obtain the graph but I want to obtain the plot far below here. I want to flip the colors. Any suggestions.

My plot: [![enter image description here][1]][1]

[![enter image description here][2]][2]

[![enter image description here][3]][3]

1

1 Answers

2
votes

looks to me that you need stat="identity" to tell geom_bar that you are directly use the value instead of doing counting.

ggplot(Crop_cond, aes(x = END_CODE, y = VALUE)) +
  geom_bar(aes(fill = CONDITION),stat = "identity",position="fill")