Entering edit mode
6.6 years ago
saadleeshehreen
▴
140
Hi, I have a dataset like following
Drug-class CRISPR-cas No CRISPR-cas
Tetracyclin(3356) 46 54
Aminoglycoside(5769) 92 8
Fuscidic acid (3) 33 67
Macrolide(2238) 16 84
Oxazolidinone(3) 100 0
I ran the sample code
Drugclass <- c("Tetracyclin", "Aminoglycoside", "Fuscidic acid", "Macrolide", "Oxazolidinone")
CRISPR-cas <- c(46, 92, 33, 16, 100 )
No CRISPR-cas <- c(54, 8, 67, 84, 0)
data <- data.frame(Drugclass, CRISPR-cas, No CRISPR-Cas)
p <- plot_ly(data, x = ~Drugclass, y = ~CRISPR-Cas, type = 'bar', name = 'CRISPR-Cas') %>%
add_trace(y = ~No CRISPR-Cas, name = 'No CRISPR-cas') %>%
layout(yaxis = list(title = '% of genome'), barmode = 'group')
But it didn't give me a plot. How to create a barplot with this data?
You need to plot p. An object of p is created. Type in "p" after you have created p (plotly object). However, OP code will throw errors in creating data frame.
I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:
What happened? Did you get an error?