You can create a group
column to distinguish between number of values for each Feature_Names
.
df1 <- transform(df1, group = ave(Feature_Names, Feature_Names, FUN = seq_along))
Here are two suggestions that you can use after creating group
columns
- Using
ggplot
:
library(ggplot2)
library(plotly)
ggplotly(ggplot(df1, aes(Feature_Names, value, fill = group)) +
geom_col(position = 'dodge'))
- Using
plotly
:
For this option you can get the data in wide format and then plot.
df2 <- tidyr::pivot_wider(df1, names_from = group, values_from = value)
plot_ly(df2,x=~Feature_Names,y=~`1`,type='bar', name = 'group 1') %>%
add_trace(y = ~`2`, name = 'group 2') %>%
layout(title= "Feature and values",
xaxis= list(title='Feature_Names'), yaxis = list(title = 'value'))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…