-1

i need to make this kind of graph in ggplot() but i'm not sure how to go about it.

i have a dataframe with the the experimental and control conditions in a single column, and the values for each condition in their own columns (C0, C1).

https://i.stack.imgur.com/c7rrP.jpg

i was thinking of using geom_bar() or facet(). i can't use stat_summary() because i'm using raw numbers as opposed to mean doing stats on values. i'm also not sure if moving the data around on the dataframe would help to graph it easier.

neilfws
  • 32,751
  • 5
  • 50
  • 63
powerzinc
  • 1
  • 1
  • It will be much easier if you can share some example data (fake is fine) in the format you're working with. That will reduce the unavoidable ambiguity of prose and make it easier for people to try out potential solutions. Best to share data in the form of code, e.g. by using `dput(YOUR_DATA)` to create a recipe to recreate your data object. – Jon Spring Dec 05 '22 at 04:07
  • Welcome to Stack Overflow. Please [make this question reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by including a small representative dataset in a plain text format. Also include any code you tried, and any error messages. – neilfws Dec 05 '22 at 04:07
  • `geom_col` will map y to height of the bars. – Jon Spring Dec 05 '22 at 04:07
  • `library(tidyverse); df %>% pivot_longer(C0:C1) %>% ggplot(aes(YOUR_X_VAR, YOUR_Y_VAR, fill = name)) + geom_col(position = "dodge")` – Jon Spring Dec 05 '22 at 04:12

1 Answers1

0
library(plotly)
library(dplyr)
library(RColorBrewer)

data.long<-melt(data)
plot_ly(x = ~group, y = ~value)%>%
  add_trace(data = data.long, color = ~variable, colors = "Set1", type = 'bar', alpha = 0.9)
jaechang
  • 29
  • 3