I have 4 data-frames storing a number (between 1 and 100) and a string, which can be either 'A', 'B', or 'C'. I want to create a scatter-plot with the x axis in the order 'A', 'B', 'C', with the numbers of each data-frame on the y-axis. The dots on the scatter-plot should be different for each of the data-frames.
To give you some idea, the data-frames are in the form
Name | Number
A | 2
A | 4
B | 5
I've tried the following, but for some reason, it adds the numbers instead of plotting them as is.
Note: class.df
is the original data-frame from which df1
, df2
, and df3
are based on. I don't want to use it, if possible.
p <- plot_ly(class.df, x = ~Name, type = 'scatter') %>%
add_trace(df1, y = ~Number, x = ~Name, mode = 'markers', name = '1') %>%
add_trace(df2, y = ~Number, x = ~Name, mode = 'markers', name = '2') %>%
add_trace(df3, y = ~Number, x = ~Name, mode = 'markers', name = '3')